title: Sequential column sum
body: <p>I have the dataframe below:</p>
  
  <pre><code>init = 0  
  final = 8000  
  out = 3000  
  vals = c(rexp(10000, 0.0002))
  </code></pre>
  
  <p>I want to add columns (30) with a linear combination of variables list above, like this:</p>
  
  <pre><code>col1 = init + vals(1,) - out  
  col2 = col1 + vals(1,) - out  
  ...  
  col30 = col29 + vals(1,) - out  
  </code></pre>
  
  <p>And do it for all 10.000 rows:</p>
  
  <pre><code>col1 = init + vals(n,) - out  
  col2 = col1 + vals(n,) - out  
  ...  
  col30 = col29 + vals(n,) - out  
  </code></pre>
  
  <p>How can I do this with a loop?</p>
  
  <p>Still, each calculated value can't be greater than "final" and not less than "init", and should be rounded to these values (8000 and 0).</p>