Check if parsed variable is a unique identifier. This function was adapted from: Source: https://edwinth.github.io/blog/unique_id/

unique_id(x, ...)

Arguments

x

vector or dataframe.

...

optional variables, e.g. name of column or a vector of names.

Value

Boolean whether variable is a unique identifier.

Examples

unique_id(iris, Species)
#>      Species
#> 1     setosa
#> 2 versicolor
#> 3  virginica
#> [1] FALSE

mtcars$name <- rownames(mtcars)
unique_id(mtcars, name)
#>                                    name
#> Mazda RX4                     Mazda RX4
#> Mazda RX4 Wag             Mazda RX4 Wag
#> Datsun 710                   Datsun 710
#> Hornet 4 Drive           Hornet 4 Drive
#> Hornet Sportabout     Hornet Sportabout
#> Valiant                         Valiant
#> Duster 360                   Duster 360
#> Merc 240D                     Merc 240D
#> Merc 230                       Merc 230
#> Merc 280                       Merc 280
#> Merc 280C                     Merc 280C
#> Merc 450SE                   Merc 450SE
#> Merc 450SL                   Merc 450SL
#> Merc 450SLC                 Merc 450SLC
#> Cadillac Fleetwood   Cadillac Fleetwood
#> Lincoln Continental Lincoln Continental
#> Chrysler Imperial     Chrysler Imperial
#> Fiat 128                       Fiat 128
#> Honda Civic                 Honda Civic
#> Toyota Corolla           Toyota Corolla
#> Toyota Corona             Toyota Corona
#> Dodge Challenger       Dodge Challenger
#> AMC Javelin                 AMC Javelin
#> Camaro Z28                   Camaro Z28
#> Pontiac Firebird       Pontiac Firebird
#> Fiat X1-9                     Fiat X1-9
#> Porsche 914-2             Porsche 914-2
#> Lotus Europa               Lotus Europa
#> Ford Pantera L           Ford Pantera L
#> Ferrari Dino               Ferrari Dino
#> Maserati Bora             Maserati Bora
#> Volvo 142E                   Volvo 142E
#> [1] TRUE