Description Usage Arguments Value Examples
View source: R/data_expectations.R
Check if a data frame has duplicates in a given column. If a vector is given, check for duplicates in the vector.
1 2 |
df |
data frame to check |
group_by_column |
character vector name of column expecting no duplicates |
stop_if_fail |
T/F for whether to consider failure an error |
report_duplicates |
T/F for whether to return a partial list of the top duplicates if failure |
return_df |
T/F whether to end function with dataframe input (as in if a check in part of a pipe) |
several options depending on whether it fails or succeeeds
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | expect_no_duplicates(mtcars, "cyl")
# [1] "top duplicates..."
# A tibble: 3 x 2
# Groups: cyl [3]
#cyl n
#<dbl> <int>
#1 4 11
#2 6 7
#3 8 14
# Error in ifelse(stop_if_fail, stop(paste0("Duplicates detected in column: ", :
Duplicates detected in column: cyl
expect_no_duplicates(rownames(mtcars))
# [1] "no vector duplicates...OK"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.