I refer to How to rename a single column in a data.frame?
# df = dataframe # old.var.name = The name you don't like anymore # new.var.name = The name you want to get names(df)[names(df) == 'old.var.name'] <- 'new.var.name' I want to use this way(or other rename way?)
names(df)[names(df) == 'old.var.name'] <- 'new.var.name' lapply for multi-layer list to rename single column, but I don't know how it iterate for sublist(such as following iris1, iris2 and iris3), let sublist rename column 'Species' to 'newSpecies'.
(If you know relevant tutorials on lapply processing multi-layer list/dataframe, you can also recommend it to me.)
irisData <- list(iris1 = iris, iris2 = iris, iris3 = iris) colnames(irisData$iris1) #[1] "Sepal.Length" "Sepal.Width" #[3] "Petal.Length" "Petal.Width" #[5] "Species"