So I have the following data.frame
num id
1 44982 44979
2 44981 44979
3 43554 43551
4 43552 43551
5 42510 42507
6 42509 42507
7 41997 41994
8 41996 41994
9 40519 40517
10 40519 40517
11 40039 40036
12 40038 40036
13 31337 31335
14 31336 31335
15 31247 31245
16 31246 31245
17 43984 28769
18 28770 28769
19 27620 27618
20 27619 27618
As can be seen, there are duplicates in the "id" column. What I would like to do is select which duplicate to keep based on the largest value in the "num" column. Thus when ecountering duplicates in the id column, the code looks at the num column, finds the highest value row and removes the lowest value. The output should look something like this.
num id
1 44982 44979
2 43554 43551
3 42510 42507
4 41997 41994
5 40519 40517
6 40039 40036
7 31337 31335
8 31247 31245
9 43984 28769
10 27620 27618
11 27497 27495
12 44317 27374
13 10892 10697
14 10612 10606
15 10445 10443
16 10361 10359
17 10063 10061
18 9673 9671
19 9601 9599
20 8148 8146
Thanks for any help in advance