genes
chr | start | end |
---|---|---|
C1 | 1 | 5 |
C2 | 7 | 15 |
C3 | 20 | 30 |
positions
chr | pos |
---|---|
C1 | 3 |
C2 | 6 |
C3 | 20 |
C4 | 25 |
I want to filter the values of each row in the second dataframe (positions) based on the values of a row in the first dataframe(genes). The filtering criteria are that the value of the column chr should be the same between both dataframes and the value pos should be larger or equal compared to the value start and smaller or equal to the value end.
The filtered dataframe would be the following:
chr | pos |
---|---|
C1 | 3 |
C3 | 20 |
I wanna do it with dplyr preferably!
Thank you in advance for your help!