[R] vignettes: .png graphics or pre-compiled .pdf

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Fri Nov 13 17:12:42 CET 2009


On Fri, 13 Nov 2009, Michael Friendly wrote:

> In a package I'm working on there is a vignette with a number of graphs that 
> result in huge .pdf files, so
> the .pdf for the vignette is around 17 Mb.  If these graphs are converted to 
> .png, and the .tex file
> is compiled with pdflatex, the resulting .pdf is ~1 Mb.
>
> I'm reluctant to put the .Rnw file into the package as is, generating the 
> huge .pdf for the vignette.
> I first tried installing the smaller .pdf file in the package by itself (no 
> .Rnw)
> together with a file inst/doc/index.html as recommended
> in 'Writing R Extensions.'  However, when the package is installed, 
> vignette() can't find it
>
>> vignette(package="Guerry")
> no vignettes found
>> vignette("MultiSpat")
> Warning message:
> vignette 'MultiSpat' *not* found
>
> Alternatively, is there a way to generate .png graphs from the .Rnw file so 
> that those are used in building
> the .pdf for the package?  AFAICS, \SweaveOpts{} offers only the choices of 
> eps/pdf = {TRUE/FALSE}.

Yes, but you can call the png() device yourself within the code chunk

<<>>=
png(file = "fig1.png", ...)
...
dev.off()
@

and then put

\includegraphics{fig1}

manually into the LaTeX. It's certainly not as nice as Sweave's automatic 
handling of figures but will work and still keep the file self-contained.
Z

> -Michael
>
> -- 
> Michael Friendly     Email: friendly AT yorku DOT ca Professor, Psychology 
> Dept.
> York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
> 4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
> Toronto, ONT  M3J 1P3 CANADA
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>




More information about the R-help mailing list