how to add more arguments of a function in do.call in R

孤人 提交于 2020-01-15 01:24:50

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/25962605/how-to-add-more-arguments-of-a-function-in-do-call-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!