title: Coerce multiple columns to factors at once
body: <p>I have a sample data frame like below:</p>
  
  <pre><code>data &lt;- data.frame(matrix(sample(1:40), 4, 10, dimnames = list(1:4, LETTERS[1:10])))
  </code></pre>
  
  <p>I want to know how can I select multiple columns and convert them together to factors. I usually do it in the way like <code>data$A = as.factor(data$A)</code>. But when the data frame is very large and contains lots of columns, this way will be very time consuming. Does anyone know of a better way to do it? </p>