Description Usage Arguments Examples
Creates a sequence number for each set of overlapping intervals
1 |
start |
start of the interval. Can be date or numeric, but must be the same as |
end |
end of the interval. Can be date or numeric, but must be the same as |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | tbl <- tibble::tribble(
~id, ~t1, ~t2,
"A", "01/01/2020", "04/01/2020",
"A", "03/01/2020", "15/01/2020",
"A", "01/02/2020", "15/02/2020",
"A", "17/02/2020", "23/02/2020",
"B", "13/02/2020", "18/02/2020",
"B", "16/02/2020", "20/02/2020"
) %>%
dplyr::mutate_at(dplyr::vars(t1, t2), lubridate::dmy)
plot(
x = tbl$t1, y = 1:nrow(tbl), col = (tbl$id == "A") + 1,
xlim = range(tbl$t1, tbl$t2)
)
points(x = tbl$t2, y = 1:nrow(tbl), col = (tbl$id == "A") + 1)
for (i in 1:nrow(tbl)) {
lines(x = c(tbl$t1[i], tbl$t2[i]), y = c(i, i), col = (tbl$id[i] == "A") + 1)
}
tbl$seq <- time_overlap(tbl$t1, tbl$t2)
tbl %>%
dplyr::group_by(id) %>%
dplyr::mutate(seq = time_overlap(t1, t2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.