For each date interval row in my dataframe, I would like to determine whether it overlaps with all other date intervals or not. Excluding itself.
A dataframe with start and end date, representing intervals:
`data <- read.table(header=TRUE,text="
start.date end.date
2019-09-01 2019-09-10
2019-09-05 2019-09-07
2019-08-25 2019-09-05
2019-10-10 2019-10-15
")`
This function lubridate::int_overlaps()
checks if two date intervals overlap or not by returning logical TRUE or FALSE.
`int_overlaps(interval(ymd("2019-09-01"),ymd("2019-09-10")), interval(ymd("2019-09-05"), ymd("2019-09-07")))
[1] TRUE
int_overlaps(interval(ymd("2019-09-01"),ymd("2019-09-10")), interval(ymd("2019-10-10"), ymd("2019-10-15")))
[1] FALSE`
I would like to iterate each date interval with the all other date intervals excluding itself using int_overlap() to determine whether it overlaps with other date or not.
The output should look like this:
`data <- read.table(header=TRUE,text="
start.date end.date overlaps
2019-09-01 2019-09-10 TRUE
2019-09-05 2019-09-07 TRUE
2019-08-25 2019-09-05 TRUE
2019-10-10 2019-10-15 FALSE
")
`