title: R - Loop through each row and fill with value from previous row
body: <p>I'd like to test whether a value from a particular column contains an NA value, and if so, fill that NA space with the value from the previous row. I'm still trying to get the hang of the <code>apply</code> family of functions.</p>
  
  <p>E.g. I want to turn this:</p>
  
  <pre><code>      Date   Balance
  2012-01-01      1000
  2012-01-02        NA
  2012-01-03        NA
  2012-01-04      1200
  2012-01-05      1215
  2012-01-06        NA
  </code></pre>
  
  <p>into:</p>
  
  <pre><code>      Date   Balance
  2012-01-01      1000
  2012-01-02      1000
  2012-01-03      1000
  2012-01-04      1200
  2012-01-05      1215
  2012-01-06      1215
  </code></pre>