title: Replace NA each column based on another vector using dplyr
body: <p>I am trying to replace NAs in a data.frame of many columns using another vector in which the replacement values for each column are given. I know how I could replace each value using a function, but not to find the value in another vector. I am searching for a dplyr approach:</p>
  
  <p>For example:</p>
  
  <pre><code>require(dplyr)
  test &lt;- data.frame(A = c(1,2,3,NA), B = c(4,5,NA,2), C = c(NA,2,2,NA), D = c(1,2,3,4))
  replace_na &lt;- c(A = 100, B = 200, C = 300)
  # Replace with median should be replace with look up value in vector based on the name of the vector or position
  test %&gt;% mutate_each_(funs(replace(., is.na(.), median(.,na.rm = T))), names(replace_na))
  expected_result &lt;- data.frame(A = c(1,2,3,100), B = c(4,5,200,2), C = c(300,2,2,300), D = c(1,2,3,4))
  &gt; expected_result
      A   B   C  D
  1   1   4 300  1
  2   2   5   2  2
  3   3 200   2  3
  4 100   2 300  4
  </code></pre>