title: How to convert integer to factor?
body: <p>Say I have the following df</p>
  
  <pre><code>x&lt;-c(1,3,2,4,1,3,2,4,1,3,2,4)
  y&lt;-c(rnorm(12))
  df&lt;-data.frame(x,y)
  </code></pre>
  
  <p>x is integer and I try to convert it to a factor using the suggestion from the R cookbook:</p>
  
  <pre><code>df[,'x']&lt;-factor(df[,'x'])
  </code></pre>
  
  <p>But it still remains an integer. I have tried a solution found on the forum</p>
  
  <pre><code>df[,'x']&lt;-lapply(df[,'x'], factor)
  </code></pre>
  
  <p>but it did not work either. Thanks.</p>