| close_small_gaps {drugprepr} | R Documentation |
Close small gaps between successive prescriptions
Description
Given a series of prescriptions in data, if one prescription
(for the same patient and drug) starts \leq min_gap days
after the previous one finishes, we extend the length of the previous
prescription to cover the gap.
Usage
close_small_gaps(data, min_gap = 0L)
Arguments
data |
A data frame containing columns |
min_gap |
Size of largest gaps to close. Default is zero, i.e. do nothing |
Value
The input data frame data, possibly with some of the
stop_dates changed.
Examples
gappy_data <- data.frame(
patid = 1,
prodcode = 'a',
start_date = Sys.Date() + (0:6) * 7,
stop_date = Sys.Date() + (0:6) * 7 + 4
)
close_small_gaps(gappy_data)
close_small_gaps(gappy_data, 7)
[Package drugprepr version 0.0.4 Index]