R重复函数不处理无与伦比

R duplicated function not handling incomparables

我正在尝试使用 duplicated 在数据框中查找仅基于两列的重复行。

当我向 incomparables 参数传递任何内容时,出现错误

dups = duplicated(data, incomparables="Age")
...
argument 'incomparables != FALSE' is not used (yet)

我想不通。

This question好像遇到过类似的问题没有反应

毫无疑问,有不同的方法可以做同样的事情,知道这也很好,因为我是 R 的初学者。

首先,通过阅读 ?duplicated 的文档,您将意识到 incomparables 参数接受不应比较的值向量而不是列名,我引用:

a vector of values that cannot be compared.

更详细

Values in incomparables will never be marked as duplicated. This is intended to be used for a fairly small set of values and will not be efficient for a very large set.

无论哪种方式,the source code 意味着即使您按照文档进行操作也无法使用它,因为此功能似乎尚未实现

if(!identical(incomparables, FALSE))    
   .NotYetUsed("incomparables != FALSE")

不过,回到你的问题,为了 运行 duplicated 两列,你可以明确命名它们,例如

duplicated(data[c("col1", "col2")]) ## (if the desired columns called col1 and col2)