Apply a function to all the elements of a data frame
<p>I am trying to apply some transformations to all the elements in a dataframe.</p>

<p>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 <code>as.data.frame</code> to each line?</p>

<pre><code>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"?
</code></pre>