[R] save the output of summary(lmList(x)) into a dataframe

Paul Johnson pauljohn32 at gmail.com
Tue Jun 16 23:40:47 CEST 2009


On Tue, Jun 16, 2009 at 3:29 AM, Cecilia Carmo<cecilia.carmo at ua.pt> wrote:
> Hi r-helpers!
>
> I need to save the output of summary() function that I’ve runned like this:
> z<- lmList(y~x1+x2| x3, na.action=na.omit,data1,subset=year==1999)
> w<-summary(z)
> The output (w) is something like this:
> Call:
>  Model: y ~ x1 + x2 | x3
>   Data: data1


Does this come close?  I'm just using the lmList example from lme4

### example(lmList) spawns an object "fm1" that I demonstrate with:


library(lme4)

example(lmList)


varnames <- names(fm1[[1]]$coefficients)



mylist <- lmlist(fm1, summary)

varnames <- names(fm1[[1]]$coefficients)


myCoefficients <- function(x, name) { x[name,] }

theintercepts <- t( sapply(mylist, myCoefficients, varnames[1]))

theSecondVar <- t( sapply(mylist, myCoefficients, varnames[2]))


I know other r-help readers will know a better way to cycle through
the variables rather than running once for each element of varnames...


-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas




More information about the R-help mailing list