I am working with data.frames that have very similar names (df1, df2,.. df7). Because most of the analysis will be done in all, I would like to automatize the process as much as possible. I have already managed to use assign when reading the files:
for(i in 1:7) {
NameFile <- paste("df",i,"_10/score.out", sep="")
OutFile <- read.table(NameFile, na.string="NA",header=TRUE,sep="\t")
NameVar <- paste("df",i,"_10", sep="")
assign(NameVar, OutFile)
}
But now I would also like to perform the operation/function also in all of them. For instance subsetting:
for(i in 1:7) {
Newname <- paste("dfsmall",i,sep="")
dftemp <- subset(df[i], p == 0 & abs(sepscore) > 0.3)
assign(Newname, dftemp)
}
I think most of the is correct but how do I call df[i]? That is, the objects that already exist with the names df1, df2(..)? And is there a cleaner way to do this?
There are a few similarish questions here, but none that would find suitable for my problem. Then again, I am prone to missing the obvious.
Thanks.