"Gesmann, Markus" <[EMAIL PROTECTED]> writes:

> Murray,
> 
> How about creating an empty list and filling it during your loop:
> 
>  mod <- list()
>  for (i in 1:6) {
>       mod[[i]] <- lm(y ~ poly(x,i))
>       print(summary(mod[[i]]))
>       }
> 
> All your models are than stored in one object and you can use lapply to
> do something on them, like:
>  lapply(mod, summary) or lapply(mod, coef)

Ouch. Make that 

mod <- vector("list",6)

Otherwise you'll be extending the vector on every pass through the
loop. 

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch 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