title: Replace NAs using mutate_at by row mean
body: <p>I'm trying to replace NA values in several columns by the mean value of all these columns. The mean value is suppose to be calculated by row.</p>
  
  <p>I've tried this code but the NAs don't get replaced:</p>
  
  <pre><code>ID Price1 Price2 Price3 Price4
  1  2.1    3      4      NA
  2  2      3      4.5    NA
  3  2      NA     4      NA
  4  NA     3      4      NA
  
  price_cols &lt;- c("Price1", "Price2", "Price3", "Price4")
  data %&gt;%
    mutate_at(price_cols, funs(if_else(is.na(.), mean(price_cols, na.rm = TRUE), as.double(.))))
  </code></pre>
  
  <p>I've also tried adding rowwise() to the piping chain but still nothing. I know it has to do with the code not really taking the mean across rows but I don't know how to change it so it does. Help!</p>