I have a data frame which looks like :
n4=
sector turb dist
1 sector1 T02 828.66
2 sector1 T04 1114.58
3 sector1 T05 1012.22
4 sector2 T03 992.64
5 sector2 T05 1012.22
6 sector2 T06 1158.38
7 sector3 T03 992.64
8 sector12 T02 828.66
9 sector12 T04 1114.58
I would like to keep the rows with unique sector name and the measure is keeping the one with minimum values in dist column :
sector turb dist
1 sector1 T02 828.66
4 sector2 T03 992.64
7 sector3 T03 992.64
8 sector12 T02 828.66
I know that I have to group them base on sector :
result = n4 %>%
dplyr::group_by(sector)
But then using select or filter command did not worked as I tried :
result = n4 %>%
dplyr::group_by(sector)%>%
dplyr::select(which.min(dist))
Any idea how could I do it ?