Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The documentation could be improved (suggestions very welcome), but here is what's there at the moment. Perhaps it should say "even within functions"? </p> <p>In <code>?":="</code> :</p> <blockquote> <p>data.tables are not copied-on-change by :=, setkey or any of the other set* functions. See copy.</p> <p>DT is modified by reference and the new value is returned. If you require a copy, take a copy first (using DT2=copy(DT)). Recall that this package is for large data (of mixed column types, with multi-column keys) where updates by reference can be many orders of magnitude faster than copying the entire table.</p> </blockquote> <p>and in <code>?copy</code> (but I realise this is muddled in with setkey) :</p> <blockquote> <p>The input is modified by reference, and returned (invisibly) so it can be used in compound statements; e.g., setkey(DT,a)[J("foo")]. If you require a copy, take a copy first (using DT2=copy(DT)). copy() may also sometimes be useful before := is used to subassign to a column by reference. See ?copy. Note that setattr is also in package bit. Both packages merely expose R's internal setAttrib function at C level, but differ in return value. bit::setattr returns NULL (invisibly) to remind you the function is used for its side effect. data.table::setattr returns the changed object (invisibly), for use in compound statements.</p> </blockquote> <p>where the last two sentences about <code>bit::setattr</code> relate to flodel's point 2, interestingly.</p> <p>Also see these related questions :</p> <p><a href="https://stackoverflow.com/q/10225098/403310">Understanding exactly when a data.table is a reference to (vs a copy of) another data.table</a><br> <a href="https://stackoverflow.com/q/8030452/403310">Pass by reference: The := operator in the data.table package</a><br> <a href="https://stackoverflow.com/q/11192325/403310">data.table 1.8.1.: “DT1 = DT2” is not the same as DT1 = copy(DT2)?</a></p> <p>I very much like this part of your question :</p> <blockquote> <p>that makes it possible to write procedures for data.table objects, incorporating both the speed of data.table and the generalizability of a function.</p> </blockquote> <p>Yes this is definitely one of the intentions. Consider how a database works: lots of different users/programs change by reference (insert/update/delete) one or more (large) tables in the database. That works fine in database land, and is more like the way data.table thinks. Hence the svSocket video on the homepage, and the desire for <code>insert</code> and <code>delete</code> (by reference, verb only, side-effect functions).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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