Description Usage Arguments Details Value Note See Also Examples
Run this function and then you can either simply discard overlapping intervals or shift them around using an appropriate algorithm.
1 |
data |
A data frame including variables |
The older implementation used isolateoverlaps
from the
intervalaverage
package and Overlap
from the DescTools
package. Here we refactor it using functions from tidyverse
instead.
A data frame of patid
, prodcode
, start_date
and
stop_date
, where intervals are either exactly overlapping or mutually
non-overlapping (but not partially overlapping), such that the union of such
intervals is equivalent to those originally provided in data
This function currently doesn't use any keys except patid
and
prodcode
. It may be desirable to add a row ID, for matching each
partial interval back to the original interval from which it was derived.
This may be relevant to models using weighted dosages.
intervalaverage::isolateoverlaps
,
foverlaps
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | set.seed(1)
overlapping_data <- data.frame(
rowid = 1:20,
patid = 1:2,
prodcode = 'a',
start_date = Sys.Date() + c(round(rexp(19, 1/7)), -20),
qty = rpois(20, 64),
ndd = sample(seq(.5, 12, by = .5), 20, replace = TRUE),
stringsAsFactors = FALSE
)
overlapping_data <- transform(overlapping_data,
stop_date = start_date + qty / ndd
)
isolate_overlaps(overlapping_data)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.