On Sun, Sep 27, 2009 at 10:36 PM, trumpetsaz <stephaniezim...@gmail.com> wrote: > > I am trying to write a function that will have an input of a vector of > functions. Here is a simplistic example. > sumstats <- c(mean,sd) > sumstats[1] > #Gives this error > #> sumstats[1] > #[[1]] > #function (x, ...) > #UseMethod("mean") > #<environment: namespace:base>
That's not an error. The code asked it to return the first function so that's what it did. > > I thought about restricting the input to character variables such as the > following > sumstats2 <- c("mean","sd") > Is there a way to change "mean" to the function mean? This gives a vector of functions given a vector of their names: sumstat1 <- lapply(sumstats2, get) ______________________________________________ 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.