check_id | R Documentation |
Test keys for uniqueness or try to find unique keys
check_id(df, ..., max_depth = 3)
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. |
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.
Sven Halvorson
check_id(mtcars)
check_id(mtcars, cyl, mpg)
check_id(mtcars, c('cyl', 'mpg'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.