MYjx
MYjx

Reputation: 4417

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)?

Upvotes: 6

Views: 3671

Answers (1)

baptiste
baptiste

Reputation: 77116

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")))

Upvotes: 9

Related Questions