baptiste / gridExtra

Miscellaneous Functions for "Grid" Graphics
http://cran.r-project.org/web/packages/gridExtra/index.html
15 stars 4 forks source link

How do I create a list of plots that can be passed to grid.arrange #31

Closed joelmo closed 8 years ago

joelmo commented 8 years ago

I can't figure out how to create a list of plots that grid.arrange accepts. Here is what I have tried:

plots = list()
p = ggplot(mpg, aes(class)) + geom_bar()
plots[1] = p
plots[2] = p
grid.arrange(... = plots)
grid.arrange(... = list(grob(p), grob(p)))
grid.arrange(... = gList(grob(p), grob(p)))

Can this be possible in gridArrange?

baptiste commented 8 years ago

Closing as this is not an issue with gridExtra. Try posting a question on StackOverflow and/or reading introductory material on the R language (most of what you suggest is not valid R syntax).

FWIW, use [[, as in plots[[1]] <- p