title: Cumulative sequence of occurrences of values
body: <p>I have a dataset that looks something like this, with a column that can have four different values: </p>
  
  <pre><code>dataset &lt;- data.frame(out = c("a","b","c","a","d","b","c","a","d","b","c","a"))
  </code></pre>
  
  <p>In R, I'd like to create a second column that tallies, in sequence, the cumulative number of rows containing a particular value. Thus the output column would look like this: </p>
  
  <pre><code>out
  1
  1
  1
  2
  1
  2
  2
  3
  2
  3
  3
  4
  </code></pre>