title: Correct syntax for mutate_if
body: <p>I would like to replace <code>NA</code> values with zeros via <code>mutate_if</code> in <code>dplyr</code>. The syntax below:</p>
  <pre><code>set.seed(1)
  mtcars[sample(1:dim(mtcars)[1], 5),
         sample(1:dim(mtcars)[2], 5)] &lt;-  NA
  
  require(dplyr)
  
  mtcars %&gt;% 
      mutate_if(is.na,0)
  
  mtcars %&gt;% 
      mutate_if(is.na, funs(. = 0))
  </code></pre>
  <p>Returns error:</p>
  <blockquote>
  <p>Error in <code>vapply(tbl, p, logical(1), ...)</code> : values must be length 1,
  but <code>FUN(X[[1]])</code> result is length 32</p>
  </blockquote>
  <p>What's the correct syntax for this operation?</p>