[R] List or matrix of object

2010-10-12 Thread Filoche
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

Re: [R] List or matrix of object

2010-10-12 Thread jim holtman
You probably need to review the Intro to R to understand indexing: f1 - function(x) sqrt(x%*%x); f2 - function(x) (2*x+1); L - list() L[[1]] - f1 L[[2]] - f2 L # contains the objects [[1]] function (x) sqrt(x %*% x) [[2]] function (x) (2 * x + 1) L[[1]](3) # now call the functions in

Re: [R] List or matrix of object

2010-10-12 Thread Greg Snow
...@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

Re: [R] List or matrix of object

2010-10-12 Thread David Winsemius
On Oct 12, 2010, at 11:17 AM, Filoche wrote: 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; You should

Re: [R] List or matrix of object

2010-10-12 Thread Filoche
Hi again everyone. I found I could use a list with l = list() l[[1]] = myObj instead of l[1] = myObj Anyone can explain me why the use of double [] is required? Regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/List-or-matrix-of-object-tp2992101p2992121.html

Re: [R] List or matrix of object

2010-10-12 Thread Greg Snow
-project.org Subject: Re: [R] List or matrix of object Hi again everyone. I found I could use a list with l = list() l[[1]] = myObj instead of l[1] = myObj Anyone can explain me why the use of double [] is required? Regards, Phil -- View this message in context: http://r

Re: [R] List or matrix of object

2010-10-12 Thread Filoche
Thank you everyone for your answers. Regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/List-or-matrix-of-object-tp2992101p2992304.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org