title: Match values in each group of a data.table column to values in a vector
body: <p>I recently started to use the data.table package to identify values in a table's column that conform to some conditions. Although and I manage to get most of the things done, now I'm stuck with this problem:</p>
  
  <p>I have a data table, table1, in which the first column (labels) is a group ID, and the second column, o.cell, is an integer. The key is on "labels"</p>
  
  <p>I have another data table, table2, containing a single column: "cell".</p>
  
  <p>Now, I'm trying to find, for each group in table1, the values from the column "o.cell" that are in the "cell" column of table2. table1 has some 400K rows divided into 800+ groups of unequal sizes. table2 has about 1.3M rows of unique cell numbers. Cell numbers in column "o.cell" table1 can be found in more than one group.</p>
  
  <p>This seems like a simple task but I can't find the right way to do it. Depending on the way I structure my call, it either gives me a different result than what I expect or it never completes and I have to end R task because it's frozen (my machine has 24 GB RAM).</p>
  
  <p>Here's an example of one of the "variant" of the calls I have tried:</p>
  
  <pre><code>overlap &lt;- table1[, list(over.cell =
                o.cell[!is.na(o.cell) &amp; o.cell %in% table2$cell]),
                by = labels]
  </code></pre>
  
  <p>I pretty sure this is the wrong way to use data tables for this task and on top of that I can't get the result I want.</p>
  
  <p>I will greatly appreciate any help. Thanks.</p>