I would like to know how to assign multiple plots generated by a function (e.g. a function from a loaded package) into either separate variables or as elements of a list/vector of sorts. Here is an example function that outputs three plots.
someFunction <- function(){
plot(1:5, 1:5)
plot(1:5, 5:1)
plot(1:10, 1:10)
}
Using recordPlot() like this allows me to assign the last generated plot to a variable but I cannot find a way to capture the other two variables.
pdf(NULL)
dev.control(displaylist="enable")
someFunction()
a <- recordPlot()
invisible(dev.off())
Here I can print the last plot that I capture.
grid::grid.newpage()
a
I've been struggling with this problem for days now, so I would really appreciate any and all help I can get.
Thanks in advance :)