删除所有重复的行,包括“引用”行 [英] Remove all duplicate rows including the "reference" row
本文介绍了删除所有重复的行,包括“引用”行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种从向量中删除所有重复元素的方法,包括 引用 元素。通过引用元素我的意思是当前用于比较的元素,以搜索其重复项。例如,如果我们考虑这个向量:
I am looking for a way to remove all duplicate elements from a vector, including the reference element. By reference element I mean the element which is currently used in comparisons, to search for its duplicates. For instance, if we consider this vector:
a = c(1,2,3,3,4,5,6,7,7,8)
我想获取:
b = c(1,2,4,5,6,8)
我知道 duplicateated()
和 unique()
不要提供我正在寻找的结果。
I am aware of duplicated()
and unique()
but they do not provide the result I am looking for.
推荐答案
这里有一种方法:
a[!(duplicated(a) | rev(duplicated(rev(a))))]
# [1] 1 2 4 5 6 8
这篇关于删除所有重复的行,包括“引用”行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文