Useful checking that duplicates of primary keys don't exist
data_frame_uniqueness_test(d, keys, display_count = 10L)
data_frame_uniqueness_assert(d, keys, display_count = 10L)
A logical
value indicating if uniqueness is satisfied.
If FALSE
, the top rows are printed to the console.
data_frame_uniqueness_test(mtcars, c("cyl"))
#> Displaying first 10 violations of uniqueness:
#> cyl row_count
#> 1 4 11
#> 2 6 7
#> 3 8 14
#> [1] FALSE
data_frame_uniqueness_test(mtcars, c("cyl", "vs"))
#> Displaying first 10 violations of uniqueness:
#> cyl vs row_count
#> 1 4 1 10
#> 2 6 0 3
#> 3 6 1 4
#> 4 8 0 14
#> [1] FALSE
data_frame_uniqueness_test(mtcars, c("cyl", "hp"))
#> Displaying first 10 violations of uniqueness:
#> cyl hp row_count
#> 1 4 66 2
#> 2 6 110 3
#> 3 6 123 2
#> 4 8 150 2
#> 5 8 175 2
#> 6 8 180 3
#> 7 8 245 2
#> [1] FALSE
data_frame_uniqueness_test(mtcars, c("cyl", "hp"), display_count=0)
#> [1] FALSE
data_frame_uniqueness_test(mtcars, c("mpg", "wt"))
#> [1] TRUE
if (FALSE) { # \dontrun{
data_frame_uniqueness_assert(mtcars, c("cyl"))
data_frame_uniqueness_assert(mtcars, c("cyl", "vs"))
data_frame_uniqueness_assert(mtcars, c("mpg", "wt"))
} # }