[R] Using multiple objects in a for loop

Daniel Yanosky dyanosky at uga.edu
Fri Nov 24 16:40:36 CET 2006


I have a situation where I want to perform the same manipulations to multiple R objects in series. I have constructed a vector () to serve as a list of the objects. However, my assign() assigns the object name (on[j]) as a character string to "temp" and not the object itself.

=======================================

fn<-c("FT1.1.01.RData","FT1.1.02.RData")

on<-c("FT1101","FT1102")

b<-1
e<-2

for (i in 1:2){

	for (j in b:e){

load(fn[j])
assign("temp",on[j])

.
.
.
rm(paste(stderr[i],".t",sep=""))
rm(temp)
rm(fn[i])
}

}

===================================

Daniel



More information about the R-help mailing list