interv_union(M)
interv_intersect(M)
NEW: Vectorized according to an idea of William Dunlap on R-help 01-2012. OLD: For the union, the intervals are first ordered by left endpoints, then a simple loop checking intersection of two adjacent intervals.
set.seed(8237)
x <- sample(1:100, 10)
M <- cbind(x, x+10)
interv_union(M)
interv_intersect(M)
Run the code above in your browser using DataLab