[R] Problem with Sweave and pdf version 1.4

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Mon Jul 9 13:55:23 CEST 2007

Dear useRs,

I'm trying to use ggplot2 in Sweave (R 2.5.1). The plots use the alpha
channel, so I need to use pdf version 1.4. Search the mailinglist
archive I found two solutions: \SweaveOpts{echo = FALSE,
pdf.version=1.4} and explicit writing to a pdf 1.4 file. The latter
works but the first doesn't. Probably I'm doing something wrong (see the
Rnw file below). The file tmp_tmp.pdf is generated but is corrupt.
Using the second option, is there a way to create the filename based on
some variable. Something like 
x <- "sometext"
filename <- paste(x, ".pdf", sep = "")
pdf(file=filename, version="1.4") 

But how can I pass the filename to \includegraphics?

The Rnw file

\SweaveOpts{echo = FALSE, pdf.version=1.4, eps = FALSE}
<<tmp, fig = T, width = 5, height = 4>>=
  x <- runif(100)
  dataset <- data.frame(x = x, y = 5 * x + rnorm(100))
  ggplot(dataset, aes(y = y, x = x)) + stat_smooth() + geom_jitter()
\caption{Here comes a caption.}
<<fig = F>>=
  pdf(file="foo.pdf", version="1.4") 
  ggplot(dataset, aes(y = y, x = x)) + stat_smooth() + geom_jitter()
\caption{Here comes a caption.}

Thanks in advance,


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

More information about the R-help mailing list