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 \documentclass[11pt]{report} \usepackage{Sweave} \SweaveOpts{echo = FALSE, pdf.version=1.4, eps = FALSE} \begin{document} \begin{figure} \centering <<tmp, fig = T, width = 5, height = 4>> library(ggplot2) 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.} \label{fig:tmp} \end{figure} \begin{figure} \centering <<fig = F>> pdf(file="foo.pdf", version="1.4") ggplot(dataset, aes(y = y, x = x)) + stat_smooth() + geom_jitter() dev.off() @ \incudegraphics{foo} \caption{Here comes a caption.} \label{fig:foo} \end{figure} \end{document} Thanks in advance, Thierry ------------------------------------------------------------------------ ---- 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 Belgium tel. + 32 54/436 185 Thierry.Onkelinx op inbo.be www.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