title: How can I replace the NULL values in dataframe with Average of Forward and backward fill?
body: <p>I've just started using R and i'm trying to replace the NULl values in each columns by the average of forward and backward values. Below is the sample dataframe that has couple of null values</p>
  
  <pre><code>  A      B     C  
    1      1    2000
    2      NA   NA
    3      4    5000
    4      NA   NA
    5      7    8000
  </code></pre>
  
  <p>I'm trying to do something like this.</p>
  
  <pre><code>  A      B      C 
    1      1     2000
    2     2.5    3500
    3      4     5000
    4     5.5    6500
    5      7     8000
  </code></pre>
  
  <p><strong><em>tidyr</em></strong> seems to do half of the work <code>df %&gt;% fill("A",.direction = c("down"))</code> but how can i replace the average of the forward and the backward values ? </p>