title: Referencing previous value in cell (R)
body: <p>I have the following data.frame:</p>
  
  <pre><code>head(data.c)
  
       mark high_mark mark_cum
        5        0        0
        7        1        1
        7        1        2
        NA       0        2
        7        1        3
        7        1        4
  </code></pre>
  
  <p>As there are NAs I need to construct an additional column of normal sequence from 1:length(mark). However, if it is NA vector cell has to take a previous value. So it must look like this:</p>
  
  <pre><code>     mark high_mark mark_cum mark_seq
        5        0        0       1 
        7        1        1       2
        7        1        2       3
        NA       0        2       3 
        7        1        3       4
        7        1        4       5
        NA       0        4       5
  </code></pre>