title: Add missing value in column with value from row above
body: <p>Every week I a incomplete dataset for a analysis. That looks like:</p>
  
  <pre><code>df1 &lt;- data.frame(var1 = c("a","","","b",""), 
               var2 = c("x","y","z","x","z"))
  </code></pre>
  
  <p>Some var1 values are missing. The dataset should end up looking like this:</p>
  
  <pre><code>df2 &lt;- data.frame(var1 = c("a","a","a","b","b"), 
               var2 = c("x","y","z","x","z"))
  </code></pre>
  
  <p>Currently I use an Excel macro to do this. But this makes it harder to automate the analysis. From now on I would like to do this in R. But I have no idea how to do this.</p>
  
  <p>Thanks for your help.</p>
  
  <p><strong>QUESTION UPDATE AFTER COMMENT</strong></p>
  
  <p>var2 is not relevant for my question. The only thing I am trying to is. Get from df1 to df2.</p>
  
  <pre><code>df1 &lt;- data.frame(var1 = c("a","","","b",""))
  df2 &lt;- data.frame(var1 = c("a","a","a","b","b"))
  </code></pre>