I have multiple data sets that are the same column structure but different row lengths. When I go to stack them, there is an occasional problem with rbind
as one file may have the column names uppercase whereas another may have lowercase. I would like to run something at the beginning that converts everything to lowercase (as this is not case sensitive).
When I do the following one-off, the conversion works. However, I am messing something up trying to do this through a loop.
This works
names(fmli3) <- tolower(names(fmli3))
Does not work
df_qtr <- c(fmli1, fmli2, fmli3, fmli4, fmli5)
for (i in 1:length(df_qtr)){
names(df_qtr[[i]]) <- tolower(names(df_qtr[[i]]))
}
Thanks in advance for the help.
EDIT: Thanks to JWilliman answer in the cross post (and Shea for pointing out), the following works:
dfs <- c("fmli1", "fmli2", "fmli3", "fmli4", "fmli5")
for(df in dfs) {
df.tmp <- get(df)
names(df.tmp) <- tolower(names(df.tmp))
assign(df, df.tmp)
}