I have 30 data frames say : data_01, data_02, .... , data_30. I am trying to remove space and "-" from column names and turning them to lower case with this code:
names(data_02) %<>%
stringr::str_remove_all("-") %>%
str_replace_all( "\\s", "_" ) %>% tolower
I have to repeat this process 30 times for 30 data frames.
Is there any way I can do this process for all the data frames with one code without merging the data frames.
I tried this: making list of data frames
dfs <- Filter(function(x) is(x, "data.frame"), mget(ls()))
lapply(dfs, function() {names () %<>%
stringr::str_remove_all("-") %>%
str_replace_all( "\\s", "_" ) %>% tolower}, return())
But it's not working.
ps: I am new user and don't know much. I would really appreciate your help. Thanks for your help.