I have number of intervals and need to find which ones would form a continous group.
In this MWE, I have Interval.id, Interval.start, and Interval.end. And I want to calculate Wanted.column.
DT <- data.table(Interval.id=c(1L, 2L, 3L, 4L, 5L, 6L),
Interval.start=c(2.0, 3.0, 4.0, 4.6, 4.7, 5.5),
Interval.end=c(4.5, 3.5, 4.8, 5.0, 4.9, 8.0),
Wanted.column=c(1L, 1L, 1L, 1L, 1L, 2L))
I suppose foverlaps
is the friend here, but I can't see how.
How can Wanted.column be calculated?