【发布时间】:2018-11-24 22:07:42
【问题描述】:
我想将相同的参数传递给几个嵌套函数。例如,给定 2 个函数:
fun1 = function(x){x^2}
fun2 = function(x,FUN,...) { x + FUN(...) }
我想实现这样的东西:
fun2(x=10,FUN=fun1) ## this returns error
在这个例子中,我想得到 10 + 10^2 = 110
的输出我已经看到这个已回答的问题:Passing arbitrary arguments to multiple nested functions in R 但我特别希望将 same 参数传递给多个嵌套函数。
【问题讨论】:
-
只是为了确定,为什么不使用工厂函数呢? (见adv-r.hadley.nz/function-factories.html)
标签: r function arguments nested-function