title: R -apply- convert many columns from numeric to factor
body: <p>I need to convert many columns that are numeric to factor type.
  An example table:</p>
  
  <pre><code>df &lt;- data.frame(A=1:10, B=2:11, C=3:12)
  </code></pre>
  
  <p>I tried with apply:</p>
  
  <pre><code>cols&lt;-c('A', 'B')
  df[,cols]&lt;-apply(df[,cols], 2, function(x){ as.factor(x)});
  </code></pre>
  
  <p>But the result is a character class.</p>
  
  <pre><code>&gt; class(df$A)
  [1] "character"
  </code></pre>
  
  <p>How can I do this without doing as.factor for each column?</p>