I have a data frame with several student IDs and the scores they obtained on various tests. However, there are instances where a student took the same test multiple times. I would like to only keep their highest score.
For example, I would like to turn
Student Subject Score
1 Math 96
1 Math 97
1 English 82
2 Math 85
2 English 72
2 English 75
into
Student Subject Score
1 Math 97
1 English 82
2 Math 85
2 English 75
I have tried
df[!duplicated(df[,c(1,2)]),]
but that just keeps the first of the repeated observations. How could I adjust this to keep the maximum?