Test which values are/are not unique in a vector

is_unique(x)

is_not_inique(x)

Arguments

x

A vector

Value

Vector of logical values indicating TRUE for values which are unique.

Examples

is_unique(1:10)
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
is_unique(c(1, 1, 1))
#> [1] FALSE FALSE FALSE
x <- c(1, 2, 3, 4, 3, 3, 1) rez <- is_unique(x) rez
#> [1] FALSE TRUE FALSE TRUE FALSE FALSE FALSE
data.frame(x = x, is_unique = rez)
#> x is_unique #> 1 1 FALSE #> 2 2 TRUE #> 3 3 FALSE #> 4 4 TRUE #> 5 3 FALSE #> 6 3 FALSE #> 7 1 FALSE