Remove all duplicate rows including the “reference” row [duplicate]

Here’s one way:

a[!(duplicated(a) | rev(duplicated(rev(a))))]
# [1] 1 2 4 5 6 8

Leave a Comment