I want give IDX with id and day.
I tried .GRP
,.I
,seq_len(.N)
but couldn't get right answer.
dt[,IDX:=.GRP,by=c("id","day")]
give same IDX if id and day is same like this :
no id FIRST_DAY LAST_DAY day IDX
1: 46 20060912 20060922 10 days 1
2: 116 20060921 20060923 0 days 2
3: 46 20060922 20061001 0 days 3
4: 46 20061001 20061014 0 days 3
5: 46 20070313 20070401 -150 days 4
6: 46 20070401 20070501 0 days 3
7: 46 20070501 20070601 0 days 3
8: 46 20070601 20070613 0 days 3
but I want give different seq IDX even id and day is same.
no id FIRST_DAY LAST_DAY day IDX
1: 46 20060912 20060922 10 days 1
2: 116 20060921 20060923 0 days 2
3: 46 20060922 20061001 0 days 3
4: 46 20061001 20061014 0 days 3
5: 46 20070313 20070401 -150 days 4
6: 46 20070401 20070501 0 days 5
7: 46 20070501 20070601 0 days 5
8: 46 20070601 20070613 0 days 5