删除 R 中具有重复条目的行
Delete rows having duplicate entries in R
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 组的行具有唯一均值,我尝试了
head(dtt[,unique(Mean),by=c("Id","RadarSeries")])
but this gives,
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
而我希望每一列都在结果数据中 table 而不仅仅是 Id、RadarSeries 和 Mean。任何想法
how to do this ?
Edit : I want max() of remaining columns.
我喜欢 dplyr
这个:
library(dplyr)
dtt %>% group_by(Id, RadarSeries, Mean) %>%
summarize_each(funs(max))
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 组的行具有唯一均值,我尝试了
head(dtt[,unique(Mean),by=c("Id","RadarSeries")]) but this gives,
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
而我希望每一列都在结果数据中 table 而不仅仅是 Id、RadarSeries 和 Mean。任何想法
how to do this ? Edit : I want max() of remaining columns.
我喜欢 dplyr
这个:
library(dplyr)
dtt %>% group_by(Id, RadarSeries, Mean) %>%
summarize_each(funs(max))