[R] overlapping intervals

From: Giovanni Coppola <gcoppola_at_ucla.edu>
Date: Sun 15 Oct 2006 - 22:44:39 GMT


Hello everybody,

I have two series of intervals, and I'd like to output the shared regions.
For example:
series1<-cbind(Start=c(10,21,40,300),End=c(20,26,70,350))
series2<-cbind(Start=c(25,60,210,500),End=c(40,100,400,1000))

 > series1

      Start End
[1,] 10 20
[2,] 21 26
[3,] 40 70
[4,] 300 350


 > series2

      Start End
[1,] 25 40
[2,] 60 100
[3,] 210 400
[4,] 500 1000

I'd like to have something like this as result:  > shared

      Start End
[1,] 25 26
[2,] 60 70
[3,] 300 350

I found this post, but the solution finds the regions shared across all the intervals.
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/59594.html Can anybody help me with this?
Thanks
Giovanni



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon Oct 16 08:51:12 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 17 Oct 2006 - 08:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.