title: Get the group index in a data.table
body: <p>I have the following data.table:</p>
  <pre><code>library(data.table)
  DT &lt;- data.table(a = c(1,2,3,4,5,6,7,8,9,10), b = c('A','A','A','B','B', 'C', 'C', 'C', 'D', 'D'), c = c(1,1,1,1,1,2,2,2,2,2))
  &gt; DT
       a b c
   1:  1 A 1
   2:  2 A 1
   3:  3 A 1
   4:  4 B 1
   5:  5 B 1
   6:  6 C 2
   7:  7 C 2
   8:  8 C 2
   9:  9 D 2
  10: 10 D 2
  </code></pre>
  <p>I want to add a column that shows the index grouped by c (starts from 1 from each group in column c), but that only changes when the value of b is changed. The result wanted is shown below:</p>
  <p><a href="https://i.stack.imgur.com/3gsQN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3gsQN.png" alt="result" /></a></p>