Re: [R] list to matrix

2013-09-11 Thread arun
Hi, Try: set.seed(48) lst1<-replicate(3,data.frame(y=rnorm(50),z=runif(50),x=sample(10:15,50,replace=TRUE)),simplify=FALSE)  t(sapply(lst1,function(u) coef(lm(y~0+x+z,data=u  #change accordingly #   x  z #[1,] -0.01020553  0.3852990 #[2,] -0.01157726  0.3986898 #[3,]  0.0178

Re: [R] list to matrix

2013-09-11 Thread PIKAL Petr
Hi Do not post HTML. Why you did not populate your list directly with coefficients by let say coef(lm.result)? Anyway, you can reveal structure of individulal list component by str(your.object[[1]]). After that you can extract coefficient component and use sapply/lapply probably with rbind. m

Re: [R] list to matrix?

2012-12-05 Thread R. Michael Weylandt
On Wed, Dec 5, 2012 at 12:02 AM, arun 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 0.052 4.06

Re: [R] list to matrix?

2012-12-04 Thread arun
am Dunlap To: R. Michael Weylandt ; arun Cc: R help ; "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) -- > but even without those, this is silly. An identity map is a real

Re: [R] list to matrix?

2012-12-04 Thread William Dunlap
roject.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of R. Michael Weylandt > Sent: Tuesday, December 04, 2012 2:59 PM > To: arun > Cc: R help; s...@gnu.org > Subject: Re: [R] list to matrix? > > On Tue, Dec 4, 2012 at 8:17 PM, arun wrote: > > Hi, > >

Re: [R] list to matrix?

2012-12-04 Thread R. Michael Weylandt
On Tue, Dec 4, 2012 at 8:17 PM, arun 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 Humbug! (In Christ

Re: [R] list to matrix?

2012-12-04 Thread arun
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)) res #    [,1] [,2]  #[1,]  5  101  #[2,] 10   46  #[3,] 15   31

Re: [R] list to matrix?

2012-12-04 Thread R. Michael Weylandt
On Tue, Dec 4, 2012 at 8:09 PM, Sam Steingold 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), > c

Re: [R] list to matrix?

2012-12-04 Thread Mark Lamias
Try: matrix(unlist(a), ncol=2, byrow=T) --Mark Lamias From: Sam Steingold 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---start---

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

2010-02-12 Thread Dan davison
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 I can

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 ma

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. > > Bu

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

2007-11-02 Thread Petr PIKAL
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) does not work for lists. How to remove NAs from a list? > > l <- list(c(1,2,3),NA,c(1,2,3)) > mat <- do.call(cbind, l) If number of

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

2007-11-02 Thread Markus Schmidberger
Thanks, I have the case that there is a NA in the list. This should not be a column. But na.omit(l) does not work for lists. How to remove NAs from a list? l <- list(c(1,2,3),NA,c(1,2,3)) mat <- do.call(cbind, l) Best Markus Dimitris Rizopoulos schrieb: > you can use do.call(), e.g., > > do.ca

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: http: