Suppose I have
f1 <- function(x) x
f2 <- function(x) x^2
funlist <- list(f1,f2)
Then I would like to evaluate funlist such that when x is 10 I should get a list with
10 and 100.
A naive way of doint this is
myf <- funlist[[1]]
do.call(paste(quote(myf)), list(x=10))
myf <- funlist[[2]]
do.call(paste(quote(myf)), list(x=10))
- but there has to be much more elegant ways of doing this. I just can't figure out
how..
Put more generally, is there a way of making R "understand" automatically that funlist
above is really a function of x?
A related question is that of anonymous functions: how to evaluate
function(x)x^2 on x<-10 without assigning the function to a name?
Thanks in advance
S�ren H�jsgaard
[[alternative HTML version deleted]]
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html