[R] How can I manipulate a data.frame that is just created by assign() while still being in the loop?

Johann Kim jk at johannkim.de
Wed Mar 9 23:56:04 CET 2011

Hello everyone,

I want to use a loop to load many files, each into a seperate variable (data.frames) and then
- still in the loop - manipulate the present variable/data.frame.

So far this works:
for (i in 1:2){
	var <- paste("var",i,sep="")
	fileName <- paste(i,"rating.txt", sep="_")
	assign(var, read.table(fileName))

But how can I now referr to var / var[i] to manipulate that data.frame?
For example: var <- var[ , -1]

} # end of the for loop

Many thanks for help!

More information about the R-help mailing list