This help topic is for R version 1.5.0. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/duplicated.html
duplicated {base}R Documentation

Determine Duplicate Elements

Description

Determines which elements of a vector of data frame are duplicates of elements with smaller subscripts, and returns a logical vector indicating which elements (rows) are duplicates.

Usage

duplicated(x, incomparables = FALSE)

Arguments

x

an atomic vector or a data fram.e

incomparables

a vector of values that cannot be compared. Currently, FALSE is the only possible value, meaning that all values can be compared.

Details

This is a generic function with methods for vectors and data frames. The data frame method works by pasting together a character representation of the rows separated by \r, so may be imperfect if the data frame has characters with embedded carriage returns or columns which do not reliably map to characters.

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)]))

data(iris)
stopifnot(duplicated(iris)[143] == TRUE)

[Package base version 1.5.0 ]