I am trying to rename columns of multiple data.frames.
To give an example, let\'s say I\'ve a list of data.frames dfA, d
I had the problem of importing a public data set and having to rename each dataframe and rename each column in each dataframe to trim whitespaces, lowercase, and replace internal spaces with periods.
Combining the above methods got me:
for (eachdf in dfs)
df.tmp <- get(eachdf)
for (eachcol in 1:length(df.tmp))
colnames(df.tmp)[eachcol] <-
str_trim(str_to_lower(str_replace_all(colnames(df.tmp)[eachcol], " ", ".")))
}
assign(eachdf, df.tmp)
}