[R] variables in object names

From: Pierce, Ken <ken.pierce_at_oregonstate.edu>
Date: Tue 12 Sep 2006 - 20:02:13 GMT

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) }    

So I assign the first value to rsq then cycle through models 2 through 5 gathering there values. The %i% in my third line indicates which object to draw from. The question is is there any way to pass a variable such as i as part of a name?  


Kenneth B. Pierce Jr.

Research Ecologist

Landscape Ecology, Modeling, Mapping and Analysis Team

PNW Research Station - USDA-FS

3200 SW Jefferson Way, Corvallis, OR 97331


541 750-7393


        [[alternative HTML version deleted]]

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. Received on Wed Sep 13 06:11:19 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 13 Sep 2006 - 06:30:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.