I have the following data
I need to subset and only keep the number of records based on Total.
Thus: for ABC, only two rows will be kept (since Total=2), and keep the records whose Count=1 and 2 (no matter missing or not). So the count=3 will not be selected.
For LMN, only 3 records will be kept (since Total=3), and keep the records whose Count=1 and 2 and 3 (no matter missing or not). So the count=4 will not be selected.
The output should be like:
I tried to use array, if then, do loops. But really a mess, I have no functional code.
Here are the data contents:
ID Total Count Time
ABC 2 1 .
ABC 2 2 00:00
ABC 2 3 .
LMN 3 1 02:25
LMN 3 4 .
LMN 3 3 04:45
LMN 3 2 07:45
Please help, Thank you!