title: Cumsum of column value equals to
body: <p>I have a dataframe that looks like this:</p>
  
  <pre><code>ID Category Parameter Color
  1    1       1          Red
  1    1       2          Green
  1    1       3          Red
  1    2       1          Green
  1    2       2          Red 
  </code></pre>
  
  <p>And I want to add a column that does the cumsum of red values, i.e, the number of red values that were seen until that row. That should be grouped by the column category and parameter. The output for this particular case, would be something like this:</p>
  
  <pre><code>ID Category Parameter Color count_red_category  count_red_parameter
  1    1       1          Red        1                   1
  1    1       2          Green      1                   0
  1    1       3          Red        2                   1
  1    2       1          Green      0                   0
  1    2       2          Red        1                   1 
  </code></pre>
  
  <p>It should count the number of reds for a category and for a parameter. One category can have many parameters, therefore the number of reds in a category should be the sum of all reds in the parameters with that specific category.</p>
  
  <p>What is the best way of doing this?</p>
  
  <p>Kind regards</p>