Re: [R] Merge postscript files into ps/pdf
On Fri, 12-Nov-2010 at 03:29PM -0500, Ralf B wrote: | I know such programs, however, for my specific problem I have an R | script that creates a report (which I have to create many times) | and I would like to append about 100 single paged post scripts at | the end as appendix. File names are controlled so it would be easy | to detect them; I just miss a useful function/package that allows | me to perhaps print them to a postscript graphics device. R is a somewhat clumsy tool to do what would be more simply done outside R, but if you insist on doing it in R, it makes sense to edit the R code that did the plots in the first place. You just need a good text editor. | | Ralf | | On Fri, Nov 12, 2010 at 11:47 AM, Greg Snow greg.s...@imail.org wrote: | The best approach if creating all the files using R is to change how you create the graphs so that they all go to one file to begin with (as mentioned by Joshua), but if some of the files are created differently (rgl, external programs), then this is not an option. | | One external program that is fairly easy to use is pdftk which will concatenate multiple pdf files into 1 (among other things). If you want more control of layout then you can use LaTeX which will read and include ps/pdf. | | If you need to use R, then you can read ps files using the grImport package and then replot them to a postscript/pdf device with onefile set to TRUE. | | -- | Gregory (Greg) L. Snow Ph.D. | Statistical Data Center | Intermountain Healthcare | greg.s...@imail.org | 801.408.8111 | | | -Original Message- | From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- | project.org] On Behalf Of Ralf B | Sent: Friday, November 12, 2010 12:07 AM | To: r-help Mailing List | Subject: [R] Merge postscript files into ps/pdf | | 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@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. | | | __ | R-help@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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@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.
Re: [R] Merge postscript files into ps/pdf
The best approach if creating all the files using R is to change how you create the graphs so that they all go to one file to begin with (as mentioned by Joshua), but if some of the files are created differently (rgl, external programs), then this is not an option. One external program that is fairly easy to use is pdftk which will concatenate multiple pdf files into 1 (among other things). If you want more control of layout then you can use LaTeX which will read and include ps/pdf. If you need to use R, then you can read ps files using the grImport package and then replot them to a postscript/pdf device with onefile set to TRUE. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Ralf B Sent: Friday, November 12, 2010 12:07 AM To: r-help Mailing List Subject: [R] Merge postscript files into ps/pdf 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@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. __ R-help@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.
Re: [R] Merge postscript files into ps/pdf
I know such programs, however, for my specific problem I have an R script that creates a report (which I have to create many times) and I would like to append about 100 single paged post scripts at the end as appendix. File names are controlled so it would be easy to detect them; I just miss a useful function/package that allows me to perhaps print them to a postscript graphics device. Ralf On Fri, Nov 12, 2010 at 11:47 AM, Greg Snow greg.s...@imail.org wrote: The best approach if creating all the files using R is to change how you create the graphs so that they all go to one file to begin with (as mentioned by Joshua), but if some of the files are created differently (rgl, external programs), then this is not an option. One external program that is fairly easy to use is pdftk which will concatenate multiple pdf files into 1 (among other things). If you want more control of layout then you can use LaTeX which will read and include ps/pdf. If you need to use R, then you can read ps files using the grImport package and then replot them to a postscript/pdf device with onefile set to TRUE. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Ralf B Sent: Friday, November 12, 2010 12:07 AM To: r-help Mailing List Subject: [R] Merge postscript files into ps/pdf 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@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. __ R-help@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.
Re: [R] Merge postscript files into ps/pdf
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.ps...@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.bie...@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@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/ __ R-help@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.
Re: [R] Merge postscript files into ps/pdf
On Fri, Nov 12, 2010 at 1:27 PM, Ralf B ralf.bie...@gmail.com wrote: 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: appending to a file is different than generating a single file. For example: pdf(file = mysillytest.pdf, onefile = TRUE) plot(1:10) # page 1 plot(10:1) # page 2 plot(11:20) # page 3 dev.off() now the file is created with 3 graphs, each on 1 page, and that is that. I felt like there used to be an argument: append = TRUE for what you wanted to do, but it seems to be gone? I am not sure how many scripts you are dealing with; perhaps you could move all graphics creation to a single script and then push everything to the same pdf() or postscript() device. If you're on a *nix system, it may be easier to just use system() to execute the appropriate command from the shell to merge all your files through your favorite merger. #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? AFAIK each time you start a new device you get a new environment. This is R so I am sure it is possible, but I do not know how to tap into a device that was opened and closed from another script. However, as long as it is the same instance of R, I would just start the pdf() device so the plots from every script were pushed to it, and then close it once the last script ran. Something like: pdf() source(script1) # (makes 4 graphs) source(script2) # (make 3 graphs) dev.off() pdf file with 7 graphs and pages written. Then again, this may not be feasible with your workflow. Cheers, Josh Ralf On Fri, Nov 12, 2010 at 2:28 AM, Joshua Wiley jwiley.ps...@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.bie...@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@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/ -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@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.
[R] Merge postscript files into ps/pdf
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@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.
Re: [R] Merge postscript files into ps/pdf
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.bie...@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@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/ __ R-help@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.