How can I arrange an arbitrary number of ggplots using grid.arrange?

You’re ALMOST there! The problem is that do.call expects your args to be in a named list object. You’ve put them in the list, but as character strings, not named list items.

I think this should work:

args.list <- c(plot.list, 2,2)
names(args.list) <- c("x", "y", "z", "nrow", "ncol")

as Ben and Joshua pointed out in the comments, I could have assigned names when I created the list:

args.list <- c(plot.list,list(nrow=2,ncol=2))

or

args.list <- list(x=x, y=y, z=x, nrow=2, ncol=2)

Leave a Comment