Re: [R] overlapping intervals

2006-10-17 Thread Giovanni Coppola
Hello Jim, thank you very much for this elegant code. It does exactly what I need. I'll check findInterval as well. Thanks again Giovanni On Oct 16, 2006, at 7:22 AM, jim holtman wrote: Here is a more general way that looks for the transitions:

Re: [R] overlapping intervals

2006-10-16 Thread jim holtman
Here is a more general way that looks for the transitions: 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)) x - rbind(series1, series2) # create +1 for start and -1 for end x.s - rbind(cbind(x[,1], 1), cbind(x[,2], -1))

Re: [R] overlapping intervals

2006-10-16 Thread Charles C. Berry
If speed is an issue as in large scale (e.g. genomic) problems, then findInterval is very helpful. See http://finzi.psych.upenn.edu/R/Rhelp02a/archive/60815.html for an example. On Sun, 15 Oct 2006, jim holtman wrote: Not the most efficient and requires integer values (maybe less

[R] overlapping intervals

2006-10-15 Thread Giovanni Coppola
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

Re: [R] overlapping intervals

2006-10-15 Thread jim holtman
Not the most efficient and requires integer values (maybe less than 1M). My results show an additional overlap at 40 - start end were the same -- does this count? If not, just delete rows that are the same in both columns. series1-cbind(Start=c(10,21,40,300),End=c(20,26,70,350))