validate (version 0.9.2)

is_unique: Test for uniquenes of records

Description

Utility function to make common tests easier.

Usage

is_unique(...)

all_unique(...)

Arguments

...

When used in a validation rule: a bare (unquoted) list of variable names. When used directly, a comma-separated list of vectors of equal length.

Value

For is_unique A logical vector that is FALSE for each record that has a duplicate.

For all_unique a single TRUE or FALSE.

Examples

Run this code
# NOT RUN {
# check that height-weight combinations are unique
d <- data.frame(X = c('a','b','c','b'), Y = c('banana','apple','banana','apple'), Z=1:4)
v <- validator(is_unique(X, Y))
values(confront(d, v))

# }

Run the code above in your browser using DataCamp Workspace