Shishir Vor
2011-Jan-31 21:35 UTC
[R] Problem with intersection between two different tables
Hi,
I'm a beginner with R.
I have two different tables with
the variable name dmr1 and tp2 a given following. v1 is the common column
field of
the both tables. In the first table column v3 is always v2+1 while in
the second table v2 and v3 hold the range. I want to know which rows
of tb1 intersect with the range between v2 and v3 of tb3. I need some one's
kind help to solve this problem.
dmr1<
v1 v2 v3 v4
"a" 22 23 3
"a" 36 37 1
"a" 54 55 0
"a" 77 78 1
"b" 80 81 4
"b" 85 86 0
"b" 99 100 1
"b" 105 106 0
"b" 120 121 1
"b" 130 131 1
"b" 140 141 0
"b" 150 151 5
"c" 172 173 0
"c" 177 178 1
"c" 190 191 6
"c" 200 201 8
"c" 220 221 0
"c" 300 301 9
"c" 310 311 10
---------------------------------
tp2<
v1 v2 v3
"a" 20 40
"a" 70 80
"b" 90 110
"b" 130 140
"c" 190 230
Thank you
Shishir
[[alternative HTML version deleted]]
Petr Savicky
2011-Feb-01 09:12 UTC
[R] Problem with intersection between two different tables
On Mon, Jan 31, 2011 at 01:35:14PM -0800, Shishir Vor wrote:> Hi, > > > I'm a beginner with R. > > > I have two different? tables with > the variable name dmr1 and tp2 a given following. v1 is the common? column? field of > the both tables. In the first table column v3 is always v2+1 while in > the second table v2 and v3 hold the range. I want to know which rows > of tb1 intersect with the range between v2 and v3 of tb3. I need some one's kind help to solve this problem.Hi. The same question was asked a few hours before. If you are not subscribed to R-help, then use the web interface https://stat.ethz.ch/pipermail/r-help/2011-January/thread.html to search the messages with subject [R] how to search to value to another table There is a reply, which tests the intervals [a, b] from tb1 for being a subset of [c, d] in tb2. If you need to test a nonempty intersection, it is slightly more complicated, but not much. Are you from the same research team? Petr Savicky.