R, conditionally remove duplicate rows
问题 I have a dataframe in R containing the columns ID.A, ID.B and DISTANCE, where distance represents the distance between ID.A and ID.B. For each value (1->n) of ID.A, there may be multiple values of ID.B and DISTANCE (i.e. there may be multiple duplicate rows in ID.A e.g. all of value 4 which each has a different ID.B and distance in that row). I would like to be able to remove rows where ID.A is duplicated, but conditional upon the distance value such that I am left with the smallest distance