<div dir="ltr">Thanks a lot. This is working for me.<div><br></div><div>Thanks and regards,</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Nov 17, 2013 at 4:41 AM, Arunkumar Srinivasan <span dir="ltr"><<a href="mailto:aragorn168b@gmail.com" target="_blank">aragorn168b@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
How about this?
</div><div>DT[CJ(c("a", "b"), c("B", "D"))]</div>
<div><div><br></div><div>Arun</div><div><br></div></div><div><div class="h5">
<p style="color:#a0a0a8">On Saturday, November 16, 2013 at 11:53 PM, Christofer Bogaso wrote:</p>
</div></div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px">
<span><div><div><div class="h5"><div><div dir="ltr">Hello all,<div><br></div><div>I am a new user of data.table and really started to liking it :)</div><div><br></div><div>I am seeking some suggestion on how I can implement 'OR'/AND' operator to fetch a subset of a data.table.</div>
<div><br></div><div>Below is my example data.table (my actual data.table is quite big):</div><div><br></div><div><div>DT = data.table(x = 1:20, y1 = rep(letters[1:4], 5), y2 = rep(LETTERS[1:4], each = 5))</div><div>setkey(DT, y1, y2)</div>
</div><div><br></div><div><div>> DT</div><div> x y1 y2</div><div> 1: 1 a A</div><div> 2: 5 a A</div><div> 3: 9 a B</div><div> 4: 13 a C</div><div> 5: 17 a D</div><div> 6: 2 b A</div><div> 7: 6 b B</div>
<div> 8: 10 b B</div><div> 9: 14 b C</div><div>10: 18 b D</div><div>11: 3 c A</div><div>12: 7 c B</div><div>13: 11 c C</div><div>14: 15 c C</div><div>15: 19 c D</div><div>16: 4 d A</div><div>17: 8 d B</div>
<div>18: 12 d C</div><div>19: 16 d D</div><div>20: 20 d D</div></div><div><br></div><div><br></div><div>Now I want to fetch those rows for which "y1 = a OR b AND y2 = B OR D"</div><div><br></div><div>with ordinary data.frame, this is straightforward to achieve, however I am wondering what could be the data.table way for fast computation.</div>
<div><br></div><div>I would really appreciate for your help/pointer.</div><div><br></div><div>Thanks and regards,</div><div><br></div></div>
</div></div></div><div><div>_______________________________________________</div><div>datatable-help mailing list</div><div><a href="mailto:datatable-help@lists.r-forge.r-project.org" target="_blank">datatable-help@lists.r-forge.r-project.org</a></div>
<div><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></div></div></div></span>
</blockquote>
<div>
<br>
</div>
</blockquote></div><br></div>