Re: [R] list to matrix

2013-09-11 Thread PIKAL Petr
. maybe sapply(lapply(your.list, coef), rbind) can do it. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of eliza botto Sent: Wednesday, September 11, 2013 4:23 PM To: r-help@r-project.org Subject: [R] list

Re: [R] list to matrix

2013-09-11 Thread arun
,]  0.01788307 -0.5624307 A.K. - Original Message - From: eliza botto eliza_bo...@hotmail.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Wednesday, September 11, 2013 10:22 AM Subject: [R] list to matrix Dear useRs, If i have a list of the following form and i want to convert

Re: [R] list to matrix?

2012-12-05 Thread R. Michael Weylandt
On Wed, Dec 5, 2012 at 12:02 AM, arun smartpink...@yahoo.com wrote: Hi, p - lapply(1:1e6, function(i)c(i, log2(i))) system.time(z1 - t(sapply(p,function(x)x))) # user system elapsed # 2.568 0.048 2.619 system.time(z1 - do.call(rbind,p)) # user system elapsed # 4.000

[R] list to matrix?

2012-12-04 Thread Sam Steingold
How do I convert a list to a matrix? --8---cut here---start-8--- list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17), c(25, 19), c(3e+05, 11), c(35, 12), c(4e+05, 25), c(45, 19), c(5e+05, 16)) as.matrix(a) [,1] [1,]

Re: [R] list to matrix?

2012-12-04 Thread Mark Lamias
Try: matrix(unlist(a), ncol=2, byrow=T) --Mark Lamias From: Sam Steingold s...@gnu.org To: r-help@r-project.org Sent: Tuesday, December 4, 2012 3:09 PM Subject: [R] list to matrix? How do I convert a list to a matrix? --8---cut here

Re: [R] list to matrix?

2012-12-04 Thread R. Michael Weylandt
On Tue, Dec 4, 2012 at 8:09 PM, Sam Steingold s...@gnu.org wrote: How do I convert a list to a matrix? --8---cut here---start-8--- list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17), c(25, 19), c(3e+05, 11), c(35, 12), c(4e+05, 25),

Re: [R] list to matrix?

2012-12-04 Thread arun
-help@r-project.org Cc: Sent: Tuesday, December 4, 2012 3:09 PM Subject: [R] list to matrix? How do I convert a list to a matrix? --8---cut here---start-8--- list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17),     c(25, 19), c(3e+05, 11), c(35

Re: [R] list to matrix?

2012-12-04 Thread R. Michael Weylandt
On Tue, Dec 4, 2012 at 8:17 PM, arun smartpink...@yahoo.com wrote: Hi, Try this: list1-list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17), c(25, 19), c(3e+05, 11), c(35, 12), c(4e+05, 25), c(45, 19), c(5e+05, 16)) res-t(sapply(list1,function(x) x)) Bah

Re: [R] list to matrix?

2012-12-04 Thread William Dunlap
To: arun Cc: R help; s...@gnu.org Subject: Re: [R] list to matrix? On Tue, Dec 4, 2012 at 8:17 PM, arun smartpink...@yahoo.com wrote: Hi, Try this: list1-list(c(5, 101), c(1e+05, 46), c(15, 31), c(2e+05, 17), c(25, 19), c(3e+05, 11), c(35, 12), c(4e+05, 25), c

Re: [R] list to matrix?

2012-12-04 Thread arun
wdun...@tibco.com To: R. Michael Weylandt michael.weyla...@gmail.com; arun smartpink...@yahoo.com Cc: R help r-help@r-project.org; s...@gnu.org s...@gnu.org Sent: Tuesday, December 4, 2012 6:28 PM Subject: RE: [R] list to matrix? No need for all this (see solutions including mine already given

[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

[R] List to matrix or to vectors conversion

2010-02-12 Thread Juan Tomas Sayago
Dear list, I have a list with 1000 x1000 lines and columns do you know how I can convert it to matrrix or data.frame. Thanks. Juan -- Juan Tomás Sayago Universidad Central http://sites.google.com/site/juantomassayago/ Objetivo: Garantizar a cada ser humano que habite en el país, una cantidad

Re: [R] List to matrix or to vectors conversion

2010-02-12 Thread Ted Harding
On 12-Feb-10 13:14:29, Juan Tomas Sayago wrote: Dear list, I have a list with 1000 x1000 lines and columns do you know how I can convert it to matrrix or data.frame. Thanks. Juan as.data.frame() will convert it to a dataframe. If you then apply as.matrix() to the result you will get a

Re: [R] List to matrix or to vectors conversion

2010-02-12 Thread Dan davison
Ted.Harding at manchester.ac.uk writes: On 12-Feb-10 13:14:29, Juan Tomas Sayago wrote: Dear list, I have a list with 1000 x1000 lines and columns Lists have neither lines nor columns. Can you explain exactly what you have? E.g. show us the code that created your list? do you know how

Re: [R] list to Matrix - remove NAs von list.

2007-11-02 Thread jim holtman
Another alternative: do.call('cbind', l[!sapply(l, function(x)all(is.na(x)))]) On 11/2/07, Petr PIKAL [EMAIL PROTECTED] wrote: Hi [EMAIL PROTECTED] napsal dne 02.11.2007 12:00:09: Thanks, I have the case that there is a NA in the list. This should not be a column. But na.omit(l)

Re: [R] list to Matrix

2007-11-02 Thread Dimitris Rizopoulos
you can use do.call(), e.g., do.call(cbind, l) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web:

[R] list to Matrix

2007-11-02 Thread Markus Schmidberger
Hello, I have a list of vectors (all the same length). How to convert the list to a matrix? Each vector should be a column. I tried this: l - list(c(1,2,3),c(1,2,3),c(1,2,3)) mat - matrix( unlist(l), nrow=length(l) ) But I think this is not very efficient. Is there a better solution? Thanks