assert_no_overlapping_intervals_dt | R Documentation |
Checks to see if the specified interval variable contains overlapping intervals.
assert_no_overlapping_intervals_dt(
dt,
id_cols,
col_stem,
identify_all_possible = FALSE,
quiet = FALSE
)
identify_overlapping_intervals_dt(
dt,
id_cols,
col_stem,
identify_all_possible = FALSE,
quiet = FALSE
)
dt |
[ |
id_cols |
[ |
col_stem |
[ |
identify_all_possible |
[ |
quiet |
[ |
identify_overlapping_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.
identify_overlapping_intervals_dt
returns a [data.table()
] with
id_cols
that have overlapping intervals. If no intervals are overlapping
then a zero-row [data.table()
] is returned.
assert_no_overlapping_intervals_dt
returns nothing but throws an error if
identify_overlapping_intervals_dt
returns a non-empty data.table.
input_dt <- data.table::data.table(
age_start = seq(0, 95, 5),
age_end = c(seq(5, 95, 5), Inf)
)
input_dt <- rbind(input_dt, data.table::data.table(age_start = c(15), age_end = c(60)))
# identify everything that is overlapping
overlapping_dt <- identify_overlapping_intervals_dt(
dt = input_dt,
id_cols = c("age_start", "age_end"),
col_stem = "age",
identify_all_possible = TRUE
)
# identify only the largest overlapping intervals
overlapping_dt <- identify_overlapping_intervals_dt(
dt = input_dt,
id_cols = c("age_start", "age_end"),
col_stem = "age",
identify_all_possible = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.