Learn R Programming

fritools (version 3.3.0)

is_valid_primary_key: Is a Key a Valid Potential Primary Key for a data.frame?

Description

I sometimes see tables with obscure structure so I try to guess their primary keys.

Usage

is_valid_primary_key(data, key, verbose = TRUE)

Arguments

data

The data.frame for which you want to find valid potential primary key.

key

Character vector containing a subset of the columns names of data.

verbose

Be verbose?

Value

TRUE, if key is a valid primary key, FALSE otherwise.

See Also

Other bits and pieces: golden_ratio(), is_difftime_less(), r_cmd_install(), round_half_away_from_zero(), str2num(), strip_off_attributes(), tapply(), throw(), weighted_variance()

Examples

Run this code
# NOT RUN {
is_valid_primary_key(mtcars, "qsec")
is_valid_primary_key(mtcars, "carb")
is_valid_primary_key(mtcars, c("qsec", "gear"))
is_valid_primary_key(mtcars, c("qsec", "carb"))
cars <- mtcars
cars$id <-  seq_len(nrow(cars))
is_valid_primary_key(cars, "id")
# }

Run the code above in your browser using DataLab