is_candidate_key: Test if a Vector or Combination of Vectors is a Candidate Key

View source: R/utils-sfmisc.R

is_candidate_keyR Documentation

Test if a Vector or Combination of Vectors is a Candidate Key

Description

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))
is_candidate_key(c(1, 2, NA))
is_candidate_key(c(1, 2, Inf))

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

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

s-fleck/sfmisc documentation built on Nov. 21, 2023, 12:29 a.m.