is_unique: Test for uniquenes of records

View source: R/syntax.R

is_uniqueR Documentation

Test for uniquenes of records

Description

Test for uniqueness of columns or combinations of columns.

Usage

is_unique(...)

all_unique(...)

n_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.

For number_unique a single number representing the number of unique values or value combinations in the arguments.

See Also

Other cross-record-helpers: contains_exactly(), do_by(), exists_any(), hb(), hierarchy(), is_complete(), is_linear_sequence()

Examples


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

# example with groupwise test
df <- data.frame(x=c(rep("a",3), rep("b",3)),y=c(1,1,2,1:3))
v <- validator(is_unique(y, by=x))
values(confront(d,v))


validate documentation built on March 24, 2022, 5:07 p.m.