assign a function to a variable in R -


the question in title. i'd :

myfunc<- pexp plot(function(x) myfunc(x, 0.5)) 

i'd call several functions given parameters in script. i'd use foreach instead of bunch of if-then-else statement :

suppose call script way :

r --slave -f script.r --args plnorm pnorm  

i'd :

#only parameters after --args args<-commandargs(trailingonly=true) in args {     plot(function(x) i(x,param1,param2)) } 

use get retrieve object given character string containing name. in case, can use getfunction, specific version retrieve functions.

for f in args {      f <- getfunction(f)      plot(function(x) f(x, param1, param2)) } 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -