3

I'm trying to use duplicated to find rows in a dataframe that are duplicate based on two columns only.

When I pass anything into the incomparables argument, I get the error

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

I can't figure this out.

This question seems to have had a similar problem with no response.

No doubt there's a different way to do the same thing, which would also be good to know, as I am a beginner in R.

Community
  • 1
  • 1
wrgrs
  • 2,467
  • 1
  • 19
  • 24

1 Answers1

5

First of all, by reading the documentation of ?duplicated you will realise that the incomparables argument accepts a vector of values that shouldn't be compared rather a column name, and I quote:

a vector of values that cannot be compared.

And in more detail

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.

Either way, the source code implies that you can't even use it even if you were following the documentation because this feature appears to not been implemented yet

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

Though, back to your question, in order to run duplicated for two columns, you can explicitly name them, for example

duplicated(data[c("col1", "col2")]) ## (if the desired columns called col1 and col2)
David Arenburg
  • 91,361
  • 17
  • 137
  • 196