[R] Merge postscript files into ps/pdf

Ralf B ralf.bierig at gmail.com
Fri Nov 12 22:27:56 CET 2010


Assuming I would go into the trouble of messing with the existing R
scripts that create mentioned postscripts/pdfs, how can I achieve that
an array of scripts append to a single ps/pdf? I would want the first
script to create the file if it does not yet exist and all other to
append to it with new pages. I tried this simple example:

#first.R
pdfFileName <- paste("C:/testfile.pdf", sep="")
pdf(pdfFileName, onefile=TRUE)
plot(c(1,2,3))
abline(v = 2)
dev.off()

#second.R
pdfFileName <- paste("C:/testfile.pdf", sep="")
pdf(pdfFileName, onefile=TRUE)
plot(c(1,2,3))
abline(h = 2)
dev.off()

The second overwrites the first and I cannot accumulate across
different scripts. I can also not do it if I happen to start different
pdf file environments in the same script despite it sharing the same
file and having the 'onefile' set to true. Is it really just limited
to the a single environment?

Ralf





On Fri, Nov 12, 2010 at 2:28 AM, Joshua Wiley <jwiley.psych at gmail.com> wrote:
> Hi Ralf,
>
> It is easy to make a bunch of graphs in one file (each on its own
> page), using the onefile = TRUE argument to postscript() or pdf()
> (depending what type of file you want).  I usually use Ghostscript for
> tinkering with already created postscript or PDF files.  To me there
> is more appropriate software than R to use if you want to
> edit/merge/manipulate postscript or PDF files.
>
> Cheers,
>
> Josh
>
> On Thu, Nov 11, 2010 at 11:07 PM, Ralf B <ralf.bierig at gmail.com> wrote:
>> I created multiple postscript files using ?postscript. How can I merge
>> them into a single postscript file using R? How can I merge them into
>> a single pdf file?
>>
>> Thanks a lot,
>> Ralf
>>
>> ______________________________________________
>> 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.
>>
>
>
>
> --
> Joshua Wiley
> Ph.D. Student, Health Psychology
> University of California, Los Angeles
> http://www.joshuawiley.com/
>



More information about the R-help mailing list