How to print R graphics to multiple pages of a PDF and multiple PDFs?

Did you look at help(pdf) ?

Usage:

 pdf(file = ifelse(onefile, "Rplots.pdf", "Rplot%03d.pdf"),
     width, height, onefile, family, title, fonts, version,
     paper, encoding, bg, fg, pointsize, pagecentre, colormodel,
     useDingbats, useKerning)

Arguments:

file: a character string giving the name of the file. For use with
      'onefile=FALSE' give a C integer format such as
      '"Rplot%03d.pdf"' (the default in that case). (See
      'postscript' for further details.)

For 1), you keep onefile at the default value of TRUE. Several plots go into the same file.

For 2), you set onefile to FALSE and choose a filename with the C integer format and R will create a set of files.


Not sure I understand.

Appending to same file (one plot per page):

pdf("myOut.pdf")
for (i in 1:10){
  plot(...)
}
dev.off()

New file for each loop:

for (i in 1:10){
  pdf(paste("myOut",i,".pdf",sep=""))
  plot(...)
  dev.off()
}

pdf(file = "Location_where_you_want_the_file/name_of_file.pdf", title="if you want any")
plot() # Or other graphics you want to have printed in your pdf
dev.off()

You can plot as many things as you want in the pdf, the plots will be added to the pdf in different pages. dev.off() closes the connection to the file and the pdf will be created and you will se something like

> dev.off()
null device 1