Filtering of date interval data within study interval. Can be used for filtering e.g. for hospital visits, which are date intervals (time periods). The function finds rows for which ival_var overlaps with interval created based on index_date, time_before and time_after.

filter_ival_olap_ival(
  .data,
  ival_var,
  index_date,
  time_before = years(2),
  time_after = days(0)
)

Arguments

ival_var

the interval to be filtered

index_date

date or other lubridate variable as reference point around which to search

time_before

the time before the index date what defines the start of filtering interval (lubridate format, e.g years(1), weeks(10), days(20) etc.)

time_after

the time after the index date (default is 0 days) what defines the start of filtering interval (lubridate format, e.g years(1), weeks(10), days(20) etc.)

Value

returns a tibble object with filtered rows

See also

filter_date_in_ival for date filtering by fixed interval

Other filter functions: filter_date_in_ival()

Examples

if (FALSE) { d <- dplyr::left_join(sample_cohort,sample_regdata) filtered_d <- d %>% filter_ival_olap_ival(ival_var = lubridate::interval(adm_date,disc_date), index_date = postingdate, time_before = years(2), time_after = days(0)) head(filtered_d) }