It is not clear exactly what you are trying to do, but this works: f1 <- function(x) sqrt(x%*%x) f2 <- function(x) {2*x+1}
L <- list(); L[[1]] = f1; L[[2]] = f2; Then you can do something like: L[[2]](5) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Filoche > Sent: Tuesday, October 12, 2010 9:17 AM > To: r-help@r-project.org > Subject: [R] List or matrix of object > > > Hi everyone. > > Is it possible in R to create a matrix or a list (vector) or R object. > For > instance, I have > > f1 <- function(x) sqrt(x%*%x); > f2 <- function(x) (2x+1); > > I would like to do something like > > L <- List(); > L[1] = f1; > L[2] = f2; > > So, is there a way to create matrix or vector that can contains R > object. > > With regards, > Phil > -- > View this message in context: http://r.789695.n4.nabble.com/List-or- > matrix-of-object-tp2992101p2992101.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. ______________________________________________ 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.