Maybe I missed something ... you don't need to use an external file to do this. 
Just specify that the results of the sweave chunk is latex. Within ERT bits:

--------->< ERT ><-----------------------------------------------------------
\SweaveOpts{echo=FALSE, print=FALSE}

<<libraries>>=
library(xtable)
@ 

----->< In your document, within a Table float: 
><---------------------------------------------------------------

<<some_table, results=tex>>=
ss.t <- with(ss[ss$Excluded != "Keep", ], table(Excluded, Ms))

colnames(ss.t) <- c("100 ms", "200 ms")

cat("\n\\begin{center}\n", sep="")
print(xtable(ss.t, align="lrr"),
     include.rownames=T, include.colnames=T,floating=F)
cat("\n\\end{center}\n\n", sep="")

@ 

------------>< end table float with caption, label, 
etc><--------------------------------------------------------

Hope this helps.

Mateo.

On Tuesday 09 June 2009, christiaan pauw wrote:
> Answering my own question for the record
> To include latex code generated by R through Sweave one has to specify a
> filename with a .tex extension save the latex files there. In that way
> Sweave doesnt print the tex code in the pdf document by saves it in the
> specified place.
> 
>  In LyX these tex documents can be included as child documents Insert > File
> >Child Document
> Generate pdf and update the pdf directly afterwards. If you find a errors,
> update a few times before looking for something else
> 
> 
> 2009/2/27 christiaan pauw <[email protected]>
> 
> > Hi Everybody
> > I started using R with LyX (through Sweave) recently (earlier today
> > actually) and can see from here that it has great potential.
> >
> > R has functions can generate latex tables which is highly cusomizable. When
> > these functions are run using sweave in LyX the do exactly what they are
> > supposed to do and generate Latex code. LyX then typesets the verbatim code
> > perfectly as in the pdf document. What I want is obviously the table and not
> > the latex code that produces the table. When I paste that code into ERT it
> > generate the table perfectly. I now want sweave to generate its output
> > inside something like ERT
> >
> > Is there a way to say to LyX "what follows here is LaTeX and it must be
> > handled like you include ERT"   ----latex code generated by sweave comes
> > here ---- "close ERT-like environment"
> >
> > regrads
> > Christiaan
> >
> 


Reply via email to