rplotgridextrar-griddo.call

How to add more arguments of a function in do.call?


My question is how I might be able to add more arguments to the do.call function.

For example, I want to draw faceted grid plots with grid.arrange, how can I add more arguments such as ncol=3 and main="main title" to the command do.call(grid.arrange,plots)?


Solution

  • consider this list of plots,

    library(ggplot2)
    library(gridExtra)
    pl = replicate(5, qplot(1,1), simplify = FALSE)
    

    you can combine it with a list of options to be passed to do.call,

    do.call(grid.arrange, c(pl, list(ncol=5, main="title")))