is_unique | R Documentation |
Test for uniqueness of columns or combinations of columns.
is_unique(...)
all_unique(...)
n_unique(...)
... |
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. |
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.
Other cross-record-helpers:
contains_exactly()
,
do_by()
,
exists_any()
,
hb()
,
hierarchy()
,
is_complete()
,
is_linear_sequence()
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.