Multiple pdf R charts

I would like to print several graphs in one PDF file. I know that this was a lot, but I would like to print different window / graphic sizes for each page, i.e. the first page is 8.5x11, the second page is 11x8.5 and so on. I tried this:

pdf(file="Combined_Graphs.pdf",onefile=TRUE,bg="white",width=8.5,height=11)
hist(rnorm(100))
pdf(file="Combined_Graphs.pdf",onefile=TRUE,width=11, height=8.5, bg="white")
hist(rnorm(100,10,2),col="blue")
dev.off()

I have to use it onefile=TRUEincorrectly, since it only generates the last graphic file before closing. Is there a better way to scale a graphics device without invoking the PDF function at the same time?

+5
source share
2 answers

, PDF , . PDF. R- system R. pdftk :

pdftk *pdf cat output combined.pdf

R:

system("pdftk *pdf cat output combined.pdf")  

combine_pdfs = function(path, output_pdf) {
  system(sprintf("pdftk %s/*pdf cat output %s"), path, output_pdf)
}
+7

, , , R, .. , PDF, PDF ( PDFjam).

onefile = TRUE pdf(), , PDF, , . PDF, , PDF-, , PDF, PDF . file pdf(), , PDF . , "Combined_Graphs.pdf".

, PDF , :

pdf(file = "foo.pdf", onefile = TRUE, width = 8.5, height = 11)
hist(rnorm(100))
hist(rnorm(100, 10, 2), col = "red")
pdf(file = "bar.pdf", width =11, height = 8.5)
hist(rnorm(100, 10, 2), col = "blue")
dev.off()
dev.off()
+4

All Articles