我正在尝试更改for循环中所有数据帧中的变量名称。数据的任何示例如下:
df1 <- data.frame(
Number = c(45,62,27,34,37,55,40),
Day = c("Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun"))
df2 <- data.frame(
Number = c(15,20,32,21,17,18,13),
Day = c("Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun"))
df3 <- data.frame(
Number = c(12,32,22,14,16,21,30),
Day = c("Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun")
L <- list(df1,df2,df3)
我当前的尝试是:
for(i in L){
colnames(L) <- c("NewName1", "NewName2")
}
这不起作用,我不明白为什么它不起作用。请告诉我是否有人能指引我正确的方向。