> Let´s say I have 10 models, each named m1,m2,m3..., and I would like
> to summarize them automatically 
> and simultaneously  - e.g., to extract parameter estimates later on 
> from all models; how can I do that?
> 
> I have tried:
> 
> x=1:10 #this creates some example data
> y=rnorm(10)
> 
> m1=lm(x~y)
> m2=lm(x~1)
> 
> sum.lms=function(x)summary(paste("m",x,sep=""))
> sum.lms(1:2)
> 
> but the paste() function always returns "m1" "m2" in quotation marks
> instead of m1 m2

Try using get, like so:
for(i in 1:2) print(summary(get(paste("m", i, sep=""))))

Regards,
Richie.

Mathematical Sciences Unit
HSL

------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:21}}

______________________________________________
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