title: data.table in R - multiple filters using multiple keys - binary search
body: <p>I don't understand how I can filter based on multiple keys in <code>data.table</code>. Take the built-in <code>mtcars</code> dataset.</p>
  
  <pre><code>DT &lt;- data.table(mtcars)
  setkey(DT, am, gear, carb)
  </code></pre>
  
  <p>Following the <a href="https://rawgit.com/wiki/Rdatatable/data.table/vignettes/datatable-keys-fast-subset.html" rel="noreferrer">vignette</a>, I know that if I want to have filtering that corresponds to <code>am == 1 &amp; gear == 4 &amp; carb == 4</code>, I can say</p>
  
  <pre><code>&gt; DT[.(1, 4, 4)]
     mpg cyl disp  hp drat    wt  qsec vs am gear carb
  1:  21   6  160 110  3.9 2.620 16.46  0  1    4    4
  2:  21   6  160 110  3.9 2.875 17.02  0  1    4    4
  </code></pre>
  
  <p>and it gives the correct result. Furthermore, if I want to have <code>am == 1 &amp; gear == 4 &amp; (carb == 4 | carb == 2)</code>, this also works</p>
  
  <pre><code>&gt; DT[.(1, 4, c(4, 2))]
      mpg cyl  disp  hp drat    wt  qsec vs am gear carb
  1: 21.0   6 160.0 110 3.90 2.620 16.46  0  1    4    4
  2: 21.0   6 160.0 110 3.90 2.875 17.02  0  1    4    4
  3: 30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2
  4: 21.4   4 121.0 109 4.11 2.780 18.60  1  1    4    2
  </code></pre>
  
  <p>However, when I want to have <code>am == 1 &amp; (gear == 3 | gear == 4) &amp; (carb == 4 | carb == 2)</code>, the plausible</p>
  
  <pre><code>&gt; DT[.(1, c(3, 4), c(4, 2))]
      mpg cyl  disp  hp drat    wt  qsec vs am gear carb
  1:   NA  NA    NA  NA   NA    NA    NA NA  1    3    4
  2: 30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2
  3: 21.4   4 121.0 109 4.11 2.780 18.60  1  1    4    2
  </code></pre>
  
  <p>fails. Could you please explain to me what is the right approach here?</p>