【发布时间】:2021-06-14 04:48:46
【问题描述】:
假设我有
> 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
df$ID 中存在唯一值和重复值。如果df$ID 中的值重复,我想保留df$tti 值最低的行。
预期输出
> df
ID tti
1 118 1.4
2 9 2.7
3 12 1.2
我正在dplyr寻找解决方案
数据
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))
【问题讨论】: