Skip to content

create a function given a string

1 message · John Fox

#
At 01:38 PM 14/12/2000 -0800, you wrote:
If I follow this correctly, then you know the names of the arguments, but 
not the statement that comprises the body of the function. How about 
something like this?

f<-function(x,y) eval(parse(text="x+y"))

I hope that this helps,
  John



________________________________
  John Fox
  Department of Sociology
  McMaster University
  email: jfox at McMaster.ca
  web: www.socsci.mcmaster.ca/jfox
________________________________

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._