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 way to get a dataframe directly without adding as.data.frame
to each line?
df = data.frame(a = LETTERS[1:5], b = LETTERS[6:10])
apply(df, 1, tolower) #Matrix
apply(df, 2, tolower) #Matrix
sapply(df, tolower) #Matrix
as.data.frame(sapply(df, tolower)) # Can I avoid "as.data.frame"?