I have two data frames:
CHR POS
10 289968
10 580270
CHR START STOP
10 250000 300000
10 700422 700500
Search #1
> subset(df1, CHR==df2$CHR & POS >= df2$START & POS <= df2$STOP)
CHR POS
1 10 289968
But if I flip the order of rows in df2, then the search does not work. For example, df2 is now like this
CHR START STOP
10 700422 700500
10 250000 300000
> subset(df1, CHR==df2$CHR & POS >= df2$START & POS <= df2$STOP)
[1] CHR POS
<0 rows> (or 0-length row.names)
Why does the order matter here?