title: Sum from element 1 to current element in R
body: <p>I've come across the <code>aggregate()</code> function and things like <code>seq_along()</code>, but I'm not sure how to solve this yet:</p>
  
  <p>For the following:</p>
  
  <pre><code>x
  1
  5
  10
  20
  </code></pre>
  
  <p>I'd like to get the following output:</p>
  
  <pre><code>y
  1
  6
  16
  36
  </code></pre>
  
  <p>It seemed to me that doing something like <code>x[1:seq_along(x)]</code> would do the trick but it seems not because <code>seq_along(x)</code> is a sequence rather than a number.</p>