I am trying to apply some transformations to all the elements in a dataframe.
When using the regular apply functions, I get a matrix back and not a dataframe. Is there a
Here's a way using dplyr:
dplyr
library(dplyr) df %>% mutate_each(funs(tolower))
We can use lapply and assign it back to 'df'
lapply
df[] <- lapply(df, tolower)
The [] preserves the same structure as the original dataset. Using apply convert it to a matrix and that is not recommended.
[]
apply
matrix