title: How to do a data.table merge operation
body: <p><em>note: this question and the following answers refer to data.table versions &lt; 1.5.3; v. 1.5.3 was released in Feb 2011 to resolve this issue.</em> see more recent treatment (03-2012): <a href="https://stackoverflow.com/questions/9914734/translating-sql-joins-on-foreign-keys-to-r-data-table-syntax">Translating SQL joins on foreign keys to R data.table syntax</a></p>
  
  <hr>
  
  <p>I've been digging through the documentation for the <a href="http://cran.r-project.org/web/packages/data.table/index.html" rel="noreferrer">data.table package</a> (a replacement for data.frame that's much more efficient for certain operations), including <a href="http://files.meetup.com/1406240/Data%20munging%20with%20SQL%20and%20R.pdf" rel="noreferrer">Josh Reich's presentation on SQL and data.table at the NYC R Meetup</a> (pdf), but can't figure this totally trivial operation out.</p>
  
  <pre><code>&gt; x &lt;- DT(a=1:3, b=2:4, key='a')
  &gt; x
       a b
  [1,] 1 2
  [2,] 2 3
  [3,] 3 4
  &gt; y &lt;- DT(a=1:3, c=c('a','b','c'), key='a')
  &gt; y
       a c
  [1,] 1 a
  [2,] 2 b
  [3,] 3 c
  &gt; x[y]
       a b
  [1,] 1 2
  [2,] 2 3
  [3,] 3 4
  &gt; merge(x,y)
    a b c
  1 1 2 a
  2 2 3 b
  3 3 4 c
  </code></pre>
  
  <p>The docs say "When [the first argument] is itself a data.table, a join is invoked similar to base::merge but uses binary search on the sorted key." Clearly this is not the case. Can I get the other columns from y into the result of x[y] with data.tables? It seems like it's just taking the rows of x where the key matches the key of y, but ignoring the rest of y entirely...</p>