title: Converting columns of a dataframe to factor
body: <p>I have a data frame with 100 columns and I want to convert them all into factor. Let's assume the data frame,</p>
  
  <pre><code>a &lt;- as.integer(c(1,2,1,2,1,1))
  b &lt;- as.integer(c(1,2,3,3,3,1))
  df &lt;- data.frame(a,b)
  </code></pre>
  
  <p>I am trying this,</p>
  
  <pre><code>library(dplyr)
  colwise(df, as.factor(df))
  </code></pre>
  
  <p>which give me an error like this,</p>
  
  <pre><code>&gt; colwise(df, as.factor(df))
  Error in sort.list(y) : 'x' must be atomic for 'sort.list'
  Have you called 'sort' on a list?
  </code></pre>
  
  <p>Any suggestion how to do this correct?
  Thanks in advance. </p>