[Rd] Sweaving in png

Thibaut Jombart jombart at biomserv.univ-lyon1.fr
Fri Mar 24 15:13:17 CET 2006


Hello list, 

despite I already posted a mail on this topic on R help, I guess this place may be more appropriate.
I'll make it shorter this time. Sorry for posting twice.

I found that using pixmap pictures in a Sweave document was sometimes almost impossible, due to the huge size of the pdf pictures produced.

The first solution I found was to save pictures in png, when too heavy in pdf. Here is an example:

### in a .rnw document ###

% here is an invisible chunck to create a picture
<<fig =FALSE,echo=FALSE>>=
png(filename='figs/myPic.png')
@

% next, R code to generate picture
<<fig=FALSE,echo=TRUE>>=
...[code to produce the figure]
@

% then, close the device. Hidden, again
<<fig =FALSE,echo=FALSE>>=
dev.off()
@

% and then, include it as a picture
\includegraphics{figs/myPic.png}

### end of the example ###

I
This is quite long, and I would have prefered to need simply: 

<<fig=TRUE,pdf=FALSE,png=TRUE>>
...[code to produce the figure]
@

So I tried to adapte the Sweave driver 'RweaveLatex' in order to do so. It worked.

The not-so-new driver is only a slight modification of RweaveLatex, and can 
generate ps, pdf or png figures; it was tested on Ubuntu64, Debian, 
several Windows systems and macOS X partforms with no detected problem.

Does someone find this useful, and/or were there better solutions I missed?

Regards,

Thibaut Jombart .

-- 
######################################
Thibaut JOMBART
CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive
Universite Lyon 1
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
Tél. : 04.72.43.29.35
Fax : 04.72.43.13.88
jombart at biomserv.univ-lyon1.fr <https://stat.ethz.ch/mailman/listinfo/r-help>



More information about the R-devel mailing list