(Ted Harding) wrote:
Greetings All,

Out of curiosity, I've just done a very primitive experiment:

  Obj <- list(Fun=sum, Dat=c(1,2,3,4))
  Obj$Fun(Obj$Dat)
  # [1] 10

That sort of thing (much more sophisticated) must be documented
mind-blowingly somewhere. Where?

Where I stand right now: The above (and its immediately obvious
generalisations, like Obj$Fun<-cos) is all I know about it so far.

Well functions are just an object in R, so lists can of course contain them. My naive understanding is that you can think of function calls as simply lists where the first element is the function name, and the rest of the list are the arguments, so:

> eval(as.call(Obj))
[1] 10

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to