Stockpile overlapping treatment intervals
Usage
stockpile_events(
events,
med_levels = NULL,
id_var = "patient_id",
tx_name = "tx_name",
tx_start = "tx_start",
tx_stop = "tx_stop",
verbose = FALSE
)Arguments
- events
A data frame with columns for treatment name, treatment start and stop dates, plus a column for unique patient identifiers.
- med_levels
An optional named list mapping treatment classes to their constituent treatment levels.
Example:
med_levels = list("statin" = c( "low_intensity_statin", "moderate_intensity_statin", "high_intensity_statin" ) )Default value:
NULL- id_var
A string specifying the patient identifier column in
events.Default value:
"patient_id".- tx_name
A string specifying the column in
eventsholding treatment names.Default value:
"tx_name"- tx_start
A string specifying the column in
eventswith treatment start dates. Must be aDateor numeric column.Default value:
"tx_start"- tx_stop
A string specifying the column in
eventswith treatment stop dates. Stop dates themselves are interpreted as the last day a patient is ON treatment (as opposed to first day OFF treatment). Must be aDateor numeric column.Default value:
"tx_stop"- verbose
Controls how much detail appears in the error message when the function detects an ambiguity it cannot resolve due to same-day start intervals. If
FALSE(default), the first 10 affected patients are listed along with a total count. IfTRUE, every affected patient is listed.
Value
A tibble with exactly four columns: the patient identifier (id_var,
same type as input), treatment name (tx_name, character), interval start
(tx_start, same type as input), and interval stop (tx_stop, same type
as input). No columns beyond these four are retained. Rows are sorted by
id_var, tx_name, then tx_start.
See also
The Data Overview vignette for worked examples of all three interval-resolution functions.