Test if a Vector or Combination of Vectors is a Candidate Key
is_candidate_key.Rd
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
.
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