Reputation: 55
I am using the following code to access data frames df1,df2 and df3 in a loop and rename them. This gives me an error. How do I tell R that its a data frame not a
for(i in c(df1,df2,df3)) {
colnames(data.frame(i))=c("var1","var2","var3")
}
Upvotes: 0
Views: 45
Reputation: 5152
Try using a list instead
dfl=list(df1,df2,df3)
for(i in 1:length(dfl)) {
colnames(dfl[[i]])<-c("var1","var2","var3")
}
Upvotes: 1