Skip to content
Prev 177129 / 398503 Next

Intersection of two sets of intervals

one way is:

list1 <- as.data.frame(list(open=c(1,5), close=c(2,10)))
list2 <- as.data.frame(list(open=c(1.5,3), close=c(2.5,10)))

data.frame(
     open = pmax(list1$open, list2$open),
     close = pmin(list1$close, list2$close)
)


I hope it helps.

Best,
Dimitris
Thomas Meyer wrote: