[R] Evaluation of functionals
h.wickham at auckland.ac.nz
Mon Apr 5 09:44:29 CEST 2004
> 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.
sapply(funlist, function(x) x(10))
> 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?
More information about the R-help