[R] Sweave and multiple figures from an R source file

michele donato michele.donato at wayne.edu
Mon Apr 12 18:08:38 CEST 2010


Hi,
I am trying to get figures from multiple source files in Sweave. My test
file is as follows

\documentclass{article}
\usepackage{Sweave}
\begin{document}
\begin{section}{notitle}
  This is a simple Sweave test
<<gethypergraphs_rhea,fig=TRUE,echo=F>>=
source("./testfig.r")
@
\\
End of the simple sweave test
\end{section}
\end{document}

where testfig.r is as simple as

plot(1:20)
plot(1:5)

The figures are correctly generated in the folder, as a .pdf/.eps with
two pages, each page a plot

the resulting tex file is

\documentclass{article}

\usepackage{Sweave}

\begin{document}
\begin{section}{notitle}
  This is a simple Sweave test
\includegraphics{coupling_images_report-gethypergraphs_rhea}
\\
End of the simple sweave test
\end{section}
\end{document}

When I compile the .tex file, however, the figures are overlapped one on
top of the other.
I tried to search for a solution, but found none...

Thanks,
Michele



More information about the R-help mailing list