On Tue, Oct 26, 2010 at 11:55 AM, Dennis Murphy <djmu...@gmail.com> wrote:
> Hi:
>
> When it comes to split, apply, combine, think plyr.
>
> library(plyr)
> ldply(split(afvtprelvefs, afvtprelvefs$basestudy),
>         function(x) coef(lm (ef ~ quartile, data=x, weights=1/ef_std)))

Or do it in two steps:

models <- dlply(aftvprelvef, "basestudy", function(x)
  lm(ef ~ quartile, data=x, weights=1/ef_std)
coefs <- ldply(models, coefs)

That way you can easily pull out other info

rsq <- function(x) summary(x)$r.squared
ldply(models, rsq)

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

______________________________________________
R-help@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.

Reply via email to