check_id: Check IDs

View source: R/check_id.R

check_idR Documentation

Check IDs

Description

Test keys for uniqueness or try to find unique keys

Usage

check_id(df, ..., max_depth = 3)

Arguments

df

A data frame

...

Columns within df. These can be quoted or NSE

max_depth

The maximum number of columns to look for a unique key among.

Details

The intent of this function is twofold. First, it will test if a set of supplied columns are a unique key. By 'unique key' we mean that each combination of those variables uniquely specifies a row in df. Supply columns to ... for this functionality.

The second purpose of check_id is to determine which sets of column(s) if any, determine a unique key for df. If any do, they will be listed. Othewise, the closest key(s) will be listed. The output in this case is a data frame of statistics on the attempts.

Author(s)

Sven Halvorson

Examples

check_id(mtcars)
check_id(mtcars, cyl, mpg)
check_id(mtcars, c('cyl', 'mpg'))

svenhalvorson/SvenR documentation built on Aug. 25, 2023, 1:31 p.m.