title: Replace missing values with the mean of surroundings values
body: <p>My dataset looks like the following (let's call it "a"):</p>
  
  <pre><code>date value
  2013-01-01 12.2
  2013-01-02 NA
  2013-01-03 NA
  2013-01-04 16.8
  2013-01-05 10.1
  2013-01-06 NA
  2013-01-07 12.0
  </code></pre>
  
  <p>I would like to replace the <code>NA</code> by the mean of the closest surroundings values (the previous and the next values in the series).</p>
  
  <p>I tried the following but I am not convinced by the output...</p>
  
  <pre><code>miss.val = which(is.na(a$value))
  library(zoo)
  z = zoo(a$value, a$date)
  z.corr = na.approx(z)
  z.corr[(miss.val - 1):(miss.val + 1), ]
  </code></pre>