我有一个data.frame()
在R
其中包含3列:
id<-c(12312, 12312, 12312, 48373, 345632, 223452)
id2<-c(1928277, 17665363, 8282922, 82827722, 1231233,12312333)
description<-c(Positive, Negative, Indetermined, Positive, Negative, Positive)
我想删除id
其中description
的值为的重复行Indetermined
。
这似乎是一个探查filter()
:
library(dplyr)
df %>%
mutate(count = 1) %>% # count all ids
group_by(id) %>%
mutate(count = sum(count),Duplicate = count>1) %>% # count how often each id occurs and mark duplicates
ungroup() %>%
filter(!Duplicate & description == "Indetermined") # filter out duplicates that are "indetermined"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句