删除R中具有重复条目的行

时间:2015-04-02 23:02:25

标签: r delete-row

    Id TimeToEnd DistanceToRadar Composite HybridScan HydrometeorType Kdp RR1
 1:  1        56              30    -99900     -99900               8   0   0
 2:  1        37              30    -99900     -99900               8   0   0
 3:  1        31              30    -99900     -99900               8   0   0
 4:  1        25              30    -99900     -99900               8   0   0
 5:  1        19              30    -99900     -99900               8   0   0
 6:  1        13              30    -99900     -99900               8   0   0
 7:  1         7              30    -99900     -99900               8   0   0
 8:  1         2              30    -99900     -99900               8   0   0
 9:  2        58              77    -99900     -99900               8   0   0
10:  2        48              77    -99900     -99900               8   0   0

    TimeToEndInversion NewDistanceToRadar NewRadarIndicator RadarSeries
 1:                  1                  1              TRUE           1
 2:                  0                  0             FALSE           1
 3:                  0                  0             FALSE           1
 4:                  0                  0             FALSE           1
 5:                  0                  0             FALSE           1
 6:                  0                  0             FALSE           1
 7:                  0                  0             FALSE           1
 8:                  0                  0             FALSE           1
 9:                  1                  1              TRUE           1
10:                  0                  0             FALSE           1
         Mean
 1: 11.125000
 2: 11.125000
 3: 11.125000
 4: 11.125000
 5: 11.125000
 6: 11.125000
 7: 11.125000
 8: 11.125000
 9:  7.416667
10:  7.416667

对于上面的数据,我希望为Id和RadarSeries组创建具有唯一Mean的行,我试过

  

头(DTT [,唯一的(平均数),通过= C("标识"" RadarSeries&#34)])        但是这给了,

Id RadarSeries        V1
1:  1           1 11.125000
2:  2           1  7.416667
3:  3           1  5.250000
4:  4           1 12.750000
5:  5           1 15.000000
6:  5           2 21.916667

虽然我希望每列都在结果数据表中,而不仅仅是Id,RadarSeries和Mean。任何想法

  

怎么做?   编辑:我想要剩余列的max()。

1 个答案:

答案 0 :(得分:0)

我喜欢dplyr

library(dplyr)
dtt %>% group_by(Id, RadarSeries, Mean) %>%
    summarize_each(funs(max))