You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
They are the same in fact, iiuc. DT[a==1] returns a new data.table. In the first example the compound [,b:=1] is applied to that new data.table and the result hasn't been assigned to a symbol so that's lost. DT1 <- DT[a==1][, b:=1] was probably intended. And that's identical to the the DT1 that the 2nd example creates.
Agreed on documentation. Maybe it should state that := assigns by reference to whatever object is "passed" immediately to the left of the square bracket. Grateful for any suggestions of what exactly to write and where. (I find that when I ask, the response it often different to what I would have added!) I just had a look and ?":=" seems to be lacking on compound examples.
I could not find anything in the documentation about how
is actually different from
Maybe the distinction should be written somewhere. This behavior surprised me.
The text was updated successfully, but these errors were encountered: