Skip to content
Prev 260613 / 398502 Next

Help with isolating and comparing data from two files.

Is this what you are after?
V1   V2 V3 V4 V5 V6
1 c22 1445  - CG  1  4
2 c22 1542  + CG  2  3
3 c22 1678  + CG 13 15
V1   V2   V3   V4 V5 V6     V7
1 c22 1440 1500 cpg: 44 56 ......
2 c22 1520 1700 cpg: 56 87 ......
3 c22 1800 1900 cpg: 58 90 ......
+     # get indices of match
+     indx <- (pos$V2 >= reg$V2[i]) & (pos$V2 <= reg$V3[i])
+     if (!any(indx)) return(NULL)  # no match
+     # create new dataframe
+     cbind(reg[rep(i, sum(indx)), 1:3], pos[indx, ])
+ })
V1   V2   V3  V1   V2 V3 V4 V5 V6
1   c22 1440 1500 c22 1445  - CG  1  4
2   c22 1520 1700 c22 1542  + CG  2  3
2.1 c22 1520 1700 c22 1678  + CG 13 15

        
On Mon, May 23, 2011 at 12:00 AM, ajn21 <ajn21 at case.edu> wrote: