title: Calculating cumulative sum for each row
body: <p>I am trying to calculate the cumulative sum for each row using the following code:</p>
  
  <pre><code>df &lt;- data.frame(count=1:10)
  
  for (loop in (1:nrow(df)))
      {df[loop,"acc_sum"] &lt;- sum(df[1:loop,"count"])}
  </code></pre>
  
  <p>But I don't like the explicit loop here, how can I modify it?</p>