[R] Sweave files into LaTex
Duncan Murdoch
murdoch.duncan at gmail.com
Sat Apr 5 02:25:52 CEST 2014
On 04/04/2014, 7:10 PM, Axel Urbiz wrote:
> Hi,
>
> I'm writing a thesis in Latex (say master.tex). I'd like to include R
> code/results from an .Rwd file. I've naively tried:
>
> 1) Add ONLY the code below in Rcode.Rnw file:
>
> \section{Exploratory data analysis}
> <<eval=TRUE, echo=FALSE>>=
> library(ggplot2)
> data(diamonds)
> head(diamonds)
> @
>
> 2) Then, in the master.tex file add the following line:
>
> \include{Rcode.Rnw}
>
> But of course, that didn't work.Any help would be much appreciated.
You want
\include{Rcode.tex}
But you have to run Sweave to produce Rcode.tex from Rcode.Rnw. The
patchDVI package has functions to make this easy if you're using
TeXWorks or some other LaTeX editors -- see the vignette.
Duncan Murdoch
More information about the R-help
mailing list