Skip to contents

Checks if all elements of the atomic vector x, or the combination of all elements of x if x is a list, are unique and neither NA or infinite.

Usage

is_candidate_key(x)

Arguments

x

a atomic vector or a list of atomic vectors

Value

TRUE/FALSE

Examples


is_candidate_key(c(1, 2, 3))
#> [1] TRUE
is_candidate_key(c(1, 2, NA))
#> [1] FALSE
is_candidate_key(c(1, 2, Inf))
#> [1] FALSE

td <- data.frame(
  x = 1:10,
  y = 1:2,
  z = 1:5
)

is_candidate_key(list(td$x, td$z))
#> [1] TRUE
# a data.frame is just a special list
is_candidate_key(td[, c("y", "z")])
#> [1] TRUE