I have a data table as below:
user time follow_group
1: 1 2017-09-01 00:01:01 1
2: 1 2017-09-01 00:01:20 1
3: 1 2017-09-01 00:03:01 1
4: 1 2017-09-01 00:10:01 2
5: 1 2017-09-01 00:11:01 2
6: 2 2017-09-01 00:01:03 1
7: 2 2017-09-01 00:01:08 1
8: 2 2017-09-01 00:03:01 1
From this I want to take all the records with highest follow_group for each user
So what I did was
data[max(follow_group), , by = list(user)]
But this returned me an error
Error in `[.data.table`(data, max(follow_group), :
'by' or 'keyby' is supplied but not j
Any help is appreciated.Thanks.