I have at least 10 ggplot plots (we can call them plot1, plot2 ....). I can output them to separate PDF files. But I prefer to output them in only one pdf file, but several pages. One page, one plot from ggplot.
I tried to list all the graphs and use ggsave, but it cannot work. Any idea or script can help? Thanks you
See the function pdffor this.
pdf
For three graphs, it will look like this (saving to your working directory with the default name). Skip the line dev.offbefore you can open the file.
dev.off
pdf() plot1 plot2 plot3 dev.off()
list1:
list1
pdf() list1 dev.off()
aosmith, ggplot2 pdf.
GG_save_pdf = function(list, filename) { #start pdf pdf(filename) #loop for (p in list) { print(p) } #end pdf dev.off() invisible(NULL) }