Skip to contents

Does the input contain a duplicate value?

Usage

isDuplicate(x)

Arguments

x

vector. Any vector type (e.g. character, logical, numeric).

Value

TRUE on success; FALSE on failure, with cause set.

Details

This check is designed to serve as a complement to the base duplicated function, which only returns TRUE after the first observed duplicate value. Our check here returns TRUE for all values that are duplicated.

Functions

  • isDuplicate(): Vectorized.

Note

Updated 2023-09-29.

Examples

## TRUE ====
x <- c("a", "a", "b", "b", "c", "d")
isDuplicate(x)
#> [1]  TRUE  TRUE  TRUE  TRUE FALSE FALSE
duplicated(x)
#> [1] FALSE  TRUE FALSE  TRUE FALSE FALSE

## FALSE ====
isDuplicate(c("a", "b", "c"))
#> [1] FALSE FALSE FALSE