duplicated {base} | R Documentation

## Determine Duplicate Elements

### Description

Determines which elements of a vector are duplicates of elements with smaller subscripts, and returns a logical vector indicating which elements are duplicates.

### Usage

    duplicated(x)

### Arguments

`x` | an atomic vector

### See Also

`unique`.

### Examples

    x <- c(9:20, 1:5, 3:7, 0:8)
    ## extract unique elements
    (xu <- x[!duplicated(x)])
    stopifnot(xu == unique(x), # but unique(x) is more efficient
              0:20 == sort(x[!duplicated(x)]))

[Package Contents]