assert_no_missing_intervals_dt | R Documentation |
Checks to see if the specified interval variable is missing any expected intervals.
assert_no_missing_intervals_dt(
dt,
id_cols,
col_stem,
expected_ints_dt,
quiet = FALSE
)
identify_missing_intervals_dt(
dt,
id_cols,
col_stem,
expected_ints_dt,
quiet = FALSE
)
dt |
[ |
id_cols |
[ |
col_stem |
[ |
expected_ints_dt |
[ |
quiet |
[ |
identify_missing_intervals_dt
works by first identifying each unique set of
intervals in dt
. Then checks one at a time the groups of rows of dt
that match each set of intervals.
expected_ints_dt = NULL
will automatically check that there are no missing
intervals between the minimum and maximum interval in each unique set. This
may miss identifying missing intervals at the beginning or end of the range.
identify_missing_intervals_dt
returns a [data.table()
] with
id_cols
that are missing expected intervals. If no intervals are missing
then a zero-row [data.table()
] is returned.
assert_no_missing_intervals_dt
returns nothing but throws an error if
identify_missing_intervals
returns a non-empty data.table.
input_dt <- data.table::data.table(
year = c(rep(2010, 20), rep(2015, 96)),
age_start = c(seq(0, 95, 5), seq(0, 95, 1)),
age_end = c(seq(5, 95, 5), Inf, seq(1, 95, 1), Inf),
value = 1
)
input_dt <- input_dt[!age_start %in% c(0, 10, 95)]
# expect intervals to cover the entire 0-Inf range
missing_dt <- identify_missing_intervals_dt(
dt = input_dt,
id_cols = c("year", "age_start", "age_end"),
col_stem = "age",
expected_ints_dt = data.table::data.table(age_start = 0, age_end = Inf)
)
# expect intervals to cover between the minimum and maximum of each grouping
missing_dt <- identify_missing_intervals_dt(
dt = input_dt,
id_cols = c("year", "age_start", "age_end"),
col_stem = "age",
expected_ints_dt = NULL
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.