detect_duped: Test for duplicates

Description Usage Arguments Details Value See Also Examples

View source: R/detect_duped.R

Description

Test for duplicates in one or a combination of vectors.

Usage

1
detect_duped(..., sep = "-^-", incomparables = FALSE)

Arguments

...

vectors to concatenate.

sep

a string used to when concatenating the vectors. See interaction.

incomparables

FALSE or a vector of incomparable—i.e., never-duplicate—values. See duplicated.

Details

This function should not be used in places of duplicated() and does not return duplicates. Instead, detect_duped() executes the common pattern

vector %in% vector[duplicated(vector)].

Providing multiple vector arguments to ... concatenates the vectors element-wise before testing for duplicates in the new vector.

Value

A logical vector corresponding to values that are duplicates or are duplicated.

See Also

duplicated and interaction.

Examples

1
2
3
4
5
6
state <- c("CA", "CA", "FL", "CA", "FL", "FL")
cd    <- c(22, 11, 22, 22, NA, NA)

data.frame(state, cd,
           dup = detect_duped(state, cd),
           dup2 = detect_duped(state, cd, incomparables = NA))

coletl/easyr documentation built on June 10, 2020, 4:58 p.m.