View source: R/assert_is_unique_dt.R
| assert_is_unique_dt | R Documentation | 
Checks to see if the rows of the input data.table are unique for each combination of the id columns.
assert_is_unique_dt(dt, id_cols)
identify_non_unique_dt(dt, id_cols)
dt | 
 [  | 
id_cols | 
 [  | 
identify_non_unique_dt returns a data.table with problematic rows
only, includes a 'count' column identifying how many times each combination
of id columns is in the dataset. assert_is_unique_dt returns nothing but
throws an error if identify_non_unique_dt returns a non empty data.table.
assertable::assert_ids to check that all unique combinations of
specified id variables list, this is appropriate when you expect your dataset
to be square.
input_dt <- data.table::data.table(location = "France", year = 2010,
                                   sex = "female",
                                   age_start = 0:95,
                                   value1 = 2, value2 = 4)
id_cols <- c("location", "year", "sex", "age_start")
non_unique_dt <- identify_non_unique_dt(input_dt, id_cols)
assert_is_unique_dt(input_dt, id_cols)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.