I have 2 lists which I wish to merge on R. Basically I wish to compare one column Chr
on both lists, and if the values match, then compare another column on the first list to see whether that value lies between two columns of the second list.
So:
List1
Probe Chr Pos
abc1 1 1000
abc2 1 1200
abc3 1 23000
abd1 2 1023
List2
Ref Chr Start End
adam 1 800 999
ben 1 1150 1210
cary 3 2000 3000
danny 5 3023 3400
Product
Probe Chr Pos Ref Start End
abc2 1 1200 ben 1150 1210
I was thinking perhaps merge(List1, List2, by="Chr")
then some sort of ifelse
filter on Product$Ref
and Product[,c("Start","End")]
. As usual, thousands of lines per list are involved so a neater alternative would be much appreciated.