title: Reset cumulative sum after 10 values
body: <p>I have data in h that I want to sum in bw and after 10 steps I want to reset the cumsum. How do I get this?</p>
  
  <pre><code>   h bw
  1  0  0
  2  0  0
  3  1  1
  4  0  1
  5  1  2
  6  0  2
  7  0  2
  8  1  3
  9  1  4
  10 1  5
  11 0  0
  12 0  0
  13 0  0
  14 0  0
  15 1  1
  16 1  2
  17 1  3
  18 0  3
  19 0  3
  20 1  4
  21 1  1
  22 0  1
  </code></pre>
  
  <p>At the moment I am working with this:</p>
  
  <pre><code>ff = function(x)
  {
    cs = cumsum(x)
    cs - cummax((x == 0) * cs)
  }
  </code></pre>
  
  <p>but it resets when h is 0 and not after 10 values. </p>
  
  <p>Thanks a lot!</p>