You can
- create .png files of each plot
- use the
png
package to read those back in and - plot them in a pdf using
grid.arrange
library(png)
library(grid)
library(gridExtra)
thePlots <- lapply (2:length(names(mtcars)), function(i) {
png("testgraph.png")
plot(mtcars[,1], mtcars[,i])
dev.off()
rasterGrob(readPNG("testgraph.png", native = FALSE),
interpolate = FALSE)
})
pdf("testgraph.pdf")
do.call(grid.arrange, c(thePlots, ncol = 3))
dev.off()