-
Notifications
You must be signed in to change notification settings - Fork 995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i
, :=
and Cartesian product (another allow.cartesian case)
#800
Comments
This is because Changing the label to feature request. |
Great. Could you answer my second point too (you may not have seen it as I added it later on) |
I have no idea what's going on there :) My best guess is that since you try to assign to a single line the value |
One way to comprehend what's going on is to realise that, even for So when you do: DT1 = unique(DT)
DT1[DT, a := 1L] internally, it first computes the matching rows in DT1[DT, which=TRUE]
# [1] 1 1 That would transform your earlier code to: DT1[c(1L,1L), a := 1L] which is quite straightforward to understand as to what's happening, and is correct behaviour. Take for example: x <- 1:5
x[c(1L,1L)] <- 10L If you'd instead done: DT1[DT, a := c(2,4)]
# id date value a
# 1: 1 1992 4.1 4 and is correct once again. However, on your first point, even though I'll add this to the other |
i
, :=
and Cartesian producti
, :=
and Cartesian product (another allow.cartesian case)
Thanks. Basically you're saying that it is due to the fact that, in base R,
modifies the first element by 4, not 3, right? I did not know about that. Thanks! |
The error is coming from the call to
|
does not throw any error even though it does not do a cartesian product.
Update: Also, I'm not clear on what happens when multiple rows in i corresponds to a row in
X
, as inIt seems to match to the last row in i in this example. Is it documented somewhere?
The text was updated successfully, but these errors were encountered: