【发布时间】:2019-03-22 10:12:37
【问题描述】:
我有一个数据框,例如:
a b c d e f g
1 Car 10/02 01/02 30/02 14 1 NA
2 Car 10/02 07/02 20/02 0 NA 7
我想得到:
a b c d e f g
1 Car 10/02 01/02 20/02 14 1 7
like a group by (a,b),为 c 和 d 选择 min Date,为 e 选择 max,为 f 和 g 选择 non-null
如何在 R 中解决它?
【问题讨论】:
-
请使用
dput和逻辑分享数据 -
我想按 (a,b) 分组选择 c 上的最小日期,d 上选择 e 上的最大数字 在 f 和 g 上选择非空
-
模式是什么。在 col d 中,您采用第二个值。在 col c 你取第一行
-
我选择最低日期