[R] list to matrix

PIKAL Petr petr.pikal at precheza.cz
Wed Sep 11 17:17:49 CEST 2013


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.

maybe

sapply(lapply(your.list, coef), rbind)

can do it.

Regards
Petr

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of eliza botto
> Sent: Wednesday, September 11, 2013 4:23 PM
> To: r-help at r-project.org
> Subject: [R] list to matrix
> 
> Dear useRs,
> If i have a list of the following form and i want to convert the
> coefficient section of each element, combined into one matrix of
> dimension 3*5. How can i do that?I hope i am clear thank in advance
> 
> [[1]]
> Call:
> lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
> Coefficients:
>      x0        x       xx        y       yy
>  1.0000  -0.4250   0.2494   0.1683  -0.7449
> 
> [[2]]
> Call:
> lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
> Coefficients:
>      x0        x       xx        y       yy
>  1.0000  -0.6355   0.5876   0.2518  -0.7293
> 
> [[3]]
> Call:
> lm(formula = mm[, i] ~ 0 + (x0 + x + xx + y + yy))
> Coefficients:
>      x0        x       xx        y       yy
>  1.0000   0.5778   0.3838   0.4207  -0.1354
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list