Hi Ken,
Not quite the way you're thinking about it, but yes, there is,
and it is very useful. See ?get for more information, but here's
the basics:
for(i in 2:5) {
thismodel <- get(paste("model", i, sep=""))
rsq <- c(rsq, summary(thismodel)$r.squared)
}
Also see ?assign for the opposite effect.
On 9/12/06, Pierce, Ken <[EMAIL PROTECTED]> wrote:
> Is there any way to put an argument into an object name. For example,
> say I have 5 objects, model1, model2, model3, model4 and model5.
>
> I would like to make a vector of the r.squares from each model by code
> such as this:
>
>
> rsq <- summary(model1)$r.squared
> for(i in 2:5){
> rsq <- c(rsq, summary(model%i%)$r.squared)
> }
>
>
--
Sarah Goslee
USDA-ARS PSWMRU
University Park, PA 16802
[EMAIL PROTECTED]
______________________________________________
[email protected] 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.