title: convert all factor columns to character in a data.frame without affecting non-factor columns
body: <p>For example I have a data.frame with both integer column and factor columns.  </p>
  
  <pre><code>data &lt;- data.frame(
      a = 1:5, 
      b = factor(c("a", "b", "c", "d", "e")), 
      c = factor(c("f", "g", "h", "i", "j")))`
  </code></pre>
  
  <p>And I want to convert b and c factor columns into character, with keeping column a as integer. </p>
  
  <p>I tried the follwing code :</p>
  
  <p><code>sapply(data, function(x) {if_else(is.factor(x), as.character(x), x)})</code></p>
  
  <p>Instead of getting the result, it throws an error:</p>
  
  <blockquote>
    <p>Error: <code>true</code> must be length 1 (length of <code>condition</code>), not 5</p>
  </blockquote>
  
  <p>I knew this can be done by mutate_if function in dplyr. But I still wonder why my code does not work for this case.</p>
  
  <p>Thank you very much for any suggestions!</p>