[R] A function as argument of another function

vito muggeo vito.muggeo at giustizia.it
Thu Apr 17 09:45:41 CEST 2003

Dear all,
I would like to write a function like:
myfun<-function(x,fn) {xx<-exp(x); x*fn(xx)}
where fn is a symbolic description of any function with its argument to be
specified. Therefore
should return 5*(2+0.3*exp(5)^2),
myfun(5,"log(y)") should return 5*log(exp(5)) and so on.

I tried with "expression" and others, but without success. How can I solve
my problem?

Many thanks,

More information about the R-help mailing list