r - Pass multiple functions and their arguments to a function -
this question has answer here:
i know can pass function function 1 of parameter , use 3 dots pass additional variables. instance:
my.function <- function(x,y,fun,...) { foo <- x+y return(fun(foo,...)) }
but if want pass 2 or more functions, each own parameters? this:
my.function <- function(x,y,fun1,fun2,param.fun1,param.fun2) { foo <- x+y return(fun1(foo, param.fun1)+fun2(x, param.fun2)) }
where param.fun1
, param.fun2
replaced 3 dots ...
, potentially many parameters.
what best way proceed?
Comments
Post a Comment