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
2
3
4
5
6
7
8
9
detect_duped(
  ...,
  sep = "-^-",
  incomparables = FALSE,
  named = FALSE,
  message = FALSE
)

duped(..., sep = "-^-", incomparables = FALSE, named = FALSE, message = 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.

named

when TRUE, the output is named with the

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 of the same length as input vectors. TRUE values mark elements 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/coler documentation built on May 12, 2021, 9:44 p.m.