shrink_interval | R Documentation |
Merge those overlapping records or records with a small interval. For instance, the two prescription records with an small gap can be considered as a same one. Or two successive hospitalizations can be merged as one.
shrink_interval(data, st, ed, gap = 1)
data |
the dataset with starting point and ending points, which is in yyyymmdd format |
st |
the column name for starting date |
ed |
the column name for ending date |
gap |
the gap between two prescription records which you would like to merge. For instance, n = 7 when two Rx records with interval less than 7 days may be consider as the same prescription. |
A data table will be generate with merged interval.
data <- data.table(id=rep(1,2), date_st=lubridate::ymd(c("2021-1-1","2021-1-4")), date_end=lubridate::ymd(c("2021-1-5","2021-1-6"))) shrink_interval(data,"date_st","date_end",gap=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.