I want to append a plot to an existing pdf long after dev.off() has been called*. After reading the pdf() help file and after reading the Q &
You could use recordPlot to store each plot in a list, then write them all to a pdf file at the end with replayPlot. Here's an example:
num.plots <- 5
my.plots <- vector(num.plots, mode='list')
for (i in 1:num.plots) {
plot(i)
my.plots[[i]] <- recordPlot()
}
graphics.off()
pdf('myplots.pdf', onefile=TRUE)
for (my.plot in my.plots) {
replayPlot(my.plot)
}
graphics.off()