【发布时间】:2014-04-19 03:42:23
【问题描述】:
假设f 是一个可以接受不同数量参数的函数。我有一个向量x,其条目用作f 的参数。
x=c(1,2,3)
f(x[], otherarguments=100)
将x 的条目作为参数传递给f 的正确且简单的方法是什么?谢谢!
例如
我要转换
t1 = traceplot(output.combined[1])
t2 = traceplot(output.combined[2])
t3 = traceplot(output.combined[3])
t4 = traceplot(output.combined[4])
grid.arrange(t1,t2,t3,t4,nrow = 2,ncol=2)
类似
tt=c()
for (i in 1:4){
tt[i] = traceplot(output.combined[i])
}
grid.arrange(tt[],nrow = 2,ncol=2)
【问题讨论】:
-
请提供一个可重现的例子
-
我猜你在找
?do.call?类似do.call("f", c(as.list(x), otherarguments=100)) -
@alexis_laz 你应该把你的评论变成一个答案:) 比我的更好。
-
@agstudy 将我的评论嵌入到您的答案中可能会更好(也许,多一点“酱汁”),这样它就可以更完整地参考这个问题。当然,随意合并它!
标签: r