I use the following Sweave template to get R output into LaTeX.

\SweaveOpts{pdf=TRUE, png=FALSE, eps=FALSE, echo=FALSE, prefix=FALSE, width=6, height=6, res=300}





<<label=FigureLabel, fig=TRUE, include=FALSE>>=
boxplot(Ozone ~ Month, data = airquality)

  \includegraphics[width=17cm, height=17cm]{FigureLabel}


This Sweave template produces R graphs in PDF format. With png=TRUE in SweaveOpts I can also get R graphs in PNG format.

Now I'm inclined to use TikZDevice and pgfSweave. As I know TikZDevice and pgfSweave produce TeX documents only not PDF. I wonder if there is a way to get figures in PDF and PNG format using SweaveOpts in some way. Thanks in advance for your help.


Try knitr, a "drop-in replacement" for Sweave. With standard settings, it produces a .tex file with TikZ code that is then compiled to PDF and included in your document, automagically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.