I have several data frames. In each data frame there is a column called Current.Net.Price . I want to change the column names to different names. Therefore I have two lists:
Names <- c("name1","name2","name3","name4","name5")
dfList <- list(df1,df2,df3,df4,df5)
I tried something like this:
i=1
for (df in dfList) {
names(df)[names(df) == "Current.Net.Price"] <- Names[i]
i<-i+1
}
But when I call
View(dfList$df2)
the column is still named Current.Net.Price
Could someone help me please? :)
Names, right?df[,Names(i)] <- df$Current.Net.Price. Easier to check if you make a new column and no overwriting of original data.