title: Reset cumsum as it reaches certain value
body: <p>I want to reset <code>cumsum</code> over a vector as it reaches certain value.</p>
  
  <p>E.g. for the following vector:</p>
  
  <pre><code>v &lt;- c(3, 5, 2, 5, 3, 4, 5, 3, 1, 4)
  </code></pre>
  
  <p>expected output is:</p>
  
  <pre><code>c(0, 0, 10, 0, 0, 22, 0, 30, 0, 0)
  </code></pre>
  
  <p>With <code>reset &lt;- 10</code> I can reduce the task to flagging the first values after the full integer:</p>
  
  <pre><code>res &lt;- cumsum(v)
  resd &lt;- res/reset
  resd
  # [1] 0.3 0.8 1.0 1.5 1.8 2.2 2.7 3.0 3.1 3.5
  </code></pre>
  
  <p>Expected output is this:</p>
  
  <pre><code>c(F, F, T, F, F, T, F, T, F, F) # or 
  c(0, 0, 1.0, 0, 0, 2.2, 0, 3.0, 0, 0)
  </code></pre>
  
  <p>I need a fast way to calculate one of those.</p>