Let's say I have
> df
ID tti
1 118 11.2
2 118 1.4
3 118 9.2
4 9 2.7
5 12 1.2
6 12 82.8
There are unique and duplicated values in df$ID
. If a value in df$ID
is duplicated, I want to keep the row with the lowest df$tti
value.
Expected output
> df
ID tti
1 118 1.4
2 9 2.7
3 12 1.2
I am looking for a solution in dplyr
Data
df <- structure(list(ID = c(118L, 118L, 118L, 9L, 12L, 12L), tti = c(11.2,
1.4, 9.2, 2.7, 1.2, 82.8)), class = "data.frame", row.names = c(NA,
-6L))