【发布时间】:2018-04-20 08:32:47
【问题描述】:
我有两个数据框:
subset <- data.frame(id=rep(1,7), country=c("CH", "CH", "CA", "DE", "FR", "AT", "DE"))
> subset
id country
1 1 CH
2 1 CH
3 1 CA
4 1 DE
5 1 FR
6 1 AT
7 1 DE
whotoremove <- data.frame(id = c(1,1), country = c("DE", "FR"))
> whotoremove
id country
1 1 DE
2 1 FR
我想从subset 中删除来自whotoremove 的元素,不仅通过匹配,而且还通过它们出现的次数。也就是说,我想得到类似的东西:
> subset
id country
1 1 CH
2 1 CH
3 1 CA
6 1 AT
7 1 DE
请注意行名:我想保留原始子集中的行名,因为我需要它们。
【问题讨论】:
标签: r data-manipulation