Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are quoting the wrong part of documentation. If you have a look at the doc of <code>[.data.table</code> you will read:</p> <blockquote> <p>When i is a data.table, x must have a key, meaning join i to x and <strong>return the rows in x that match</strong>. An equi-join is performed between each column in i to each column in x’s key in order. This is similar to base R functionality of sub- setting a matrix by a 2-column matrix, and in higher dimensions subsetting an n-dimensional array by an n-column matrix</p> </blockquote> <p>I admit the description of the package (the part you quoted) is somewhat confusing, because it seems to say that the "["-operation can be used instead of merge. But I think what it says is: if x and y are both data.tables we use a join on an index (which is invoked like merge) instead of binary search.</p> <hr> <p><em>One more thing:</em></p> <p>The data.table library I installed via <code>install.packages</code> was missing the <code>merge.data.table method</code>, so using <code>merge</code> would call <code>merge.data.frame</code>. After installing the <a href="http://r-forge.r-project.org/projects/datatable/" rel="nofollow noreferrer">package from R-Forge</a> R used the faster <code>merge.data.table</code> method. </p> <p>You can check if you have the merge.data.table method by checking the output of:</p> <pre><code>methods(generic.function="merge") </code></pre> <hr> <p><strong>EDIT [Answer no longer valid]:</strong> This answer refers to data.table version 1.3. In version 1.5.3 the behaviour of data.table changed and x[y] returns the expected results. Thank you <a href="https://stackoverflow.com/users/403310/matthew-dowle">Matthew Dowle</a>, author of data.table, for pointing this out in the comments.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload