duplicated()

  • duplicated() returns a logical vector indicating whether a each element in x is repeated in x
x <- sample(1:10, 10, replace = TRUE)
duplicated(x)
##  [1] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE
# vs.
match(x, unique(x))
##  [1] 1 2 3 1 4 5 6 7 8 1