When there are duplicate rows with one column being different (Rate), how do you remove the duplicates that are smaller - keeping the higher value Rate and not altering the other data. I want to conditionally select, when there are duplicates, the higher value in the Rate column. Any tips? I did a group_by and summarised a count to find duplicates. I filtered down the df to the duplicates and removed the smaller values with a filter using & and was going to rbind it back but there has to be a quicker way?
| Town |
Occupation |
Rate |
| Chicago |
Teacher |
20 |
| Chicago |
Teacher |
25 |
| Madison |
Nurse |
0 |
| Madison |
Nurse |
35 |
| Madison |
Doctor |
45 |
| Madison |
Custodian |
33 |
| Chicago |
Dental Hygienist |
22 |
| Town |
Occupation |
Rate |
| Chicago |
Teacher |
25 |
| Madison |
Nurse |
35 |
| Madison |
Doctor |
45 |
| Madison |
Custodian |
33 |
| Chicago |
Dental Hygienist |
22 |