base R melt / unstack , :
ranges<- data.frame(start = c(65.72000,65.72187, 65.94312,73.75625,89.61625,105.1,104.99),stop = c(79.72187,79.72375,79.94312,87.75625,104.94062,110.22,108.01))
ranges
library(reshape2)
ranges <- melt(ranges)
ranges <- ranges[order(ranges$value),]
ranges
Now, as can be seen from the above (with one reasonable assumption that we have an initial value, which is the smallest of all values, and a stop value, which is the largest of all values), the problem boils down to finding a pattern stop, which follows startin sequential lines , and this will be the only thing that interests us (to find overlapping ranges), except for the first and last lines. The following code allows:
indices <- intersect(which(ranges$variable=='start')-1, which(ranges$variable=='stop'))
unstack(ranges[c(1, sort(c(indices, indices+1)), nrow(ranges)),], value~variable)
source
share