如何在R中提取纯唯一值(无重复值)?
我正在尝试在R中提取纯唯一值。
例如:
vec <- c("a", "b", "c","c")
使用doplicate()
我得到:
vec[!duplicated(vec, fromLast=TRUE)]
[1] "a" "b" "c"
但是我想要纯唯一值,因此只有“
“ B”
。
使用unique()
我获得相同的输出。
有人知道如何解决这个问题吗?
I'm trying to extract pure unique values in R.
For example:
vec <- c("a", "b", "c","c")
Using duplicate()
I get:
vec[!duplicated(vec, fromLast=TRUE)]
[1] "a" "b" "c"
But I want the pure unique values, so only "a"
and "b"
.
Using unique()
I get the same output.
Anyone know how to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将以下代码与
AVE
使用以下代码,该代码计算唯一值的length
,并且仅采用长度为1的元素来跳过重复:输出:输出:
You can use the following code with
ave
which counts thelength
of unique values and takes only the elements whose length is 1 to skip the duplicates:Output: