title: Convert all data frame character columns to factors
body: <p>Given a (pre-existing) data frame that has columns of various types, what is the simplest way to convert all its character columns to factors, without affecting any columns of other types?</p>
  
  <p>Here's an example <code>data.frame</code>:</p>
  
  <pre><code>df &lt;- data.frame(A = factor(LETTERS[1:5]),
                   B = 1:5, C = as.logical(c(1, 1, 0, 0, 1)),
                   D = letters[1:5],
                   E = paste(LETTERS[1:5], letters[1:5]),
                   stringsAsFactors = FALSE)
  df
  #   A B     C D   E
  # 1 A 1  TRUE a A a
  # 2 B 2  TRUE b B b
  # 3 C 3 FALSE c C c
  # 4 D 4 FALSE d D d
  # 5 E 5  TRUE e E e
  str(df)
  # 'data.frame':  5 obs. of  5 variables:
  #  $ A: Factor w/ 5 levels "A","B","C","D",..: 1 2 3 4 5
  #  $ B: int  1 2 3 4 5
  #  $ C: logi  TRUE TRUE FALSE FALSE TRUE
  #  $ D: chr  "a" "b" "c" "d" ...
  #  $ E: chr  "A a" "B b" "C c" "D d" ...
  </code></pre>
  
  <p>I know I can do:</p>
  
  <pre><code>df$D &lt;- as.factor(df$D)
  df$E &lt;- as.factor(df$E)
  </code></pre>
  
  <p>Is there a way to automate this process a bit more?</p>