I have two data.frames each with three columns: chrom, start & stop, let\'s call them rangesA and rangesB. For each row of rangesA, I\'m looking to find which (if any)
This would be a lot easier / faster if you can merge the two objects first.
ranges <- merge(rangesA,rangesB,by="chrom",suffixes=c("A","B")) ranges[with(ranges, startB <= startA & stopB >= stopA),] # chrom startA stopA startB stopB #1 1 200 250 200 265 #2 5 100 105 99 106