[R] coef(summary) and plyr

David Winsemius dwinsemius at comcast.net
Mon Aug 9 15:33:55 CEST 2010


On Aug 9, 2010, at 7:51 AM, moleps wrote:

> Dear all,
>
> I´m having trouble getting a list of regression variables back into  
> a dataframe.
>
> mydf <- data.frame(x1=rnorm(100), x2=rnorm(100), x3=rnorm(100))
>
> mydf$fac<-factor(sample((0:2),replace=T,100))
>
> mydf$y<- mydf$x1+0.01+mydf$x2*3-mydf$x3*19+rnorm(100)
>
> dlply(mydf,.(fac),function(df) lm(y~x1+x2+x3,data=df))->dl
>
> here I´d like to use
>
> ldply(dl,coef(summary)) or something similar but I cant figure it  
> out...

dfdl <- ldply(dl, function(x) coef(summary(x)) )

Doesn't create a grouping variable, so:

dfdl$group=rep(0:2, each=4)


David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list