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
If one tries to set the key on an intermediate expression before continuing, the flow breaks down, as the setkey has to be in front and the whole thing becomes a mess. Here's a random example (that doesn't do anything, and can be done differently, but imagine more complex stuff instead, e.g. http://stackoverflow.com/a/25628423/817778) of what I have in mind:
dt = data.table(a = 1:6, b = 1:2)
setkey(dt[, a[1], by = b], V1)[, c := 2*V1]
For a short period of time someone pointed out (I forget who, sorry) that it can be done like so:
dt[, a[1], by = b][, setkey(.SD, V1)][, c := 2*V1]
which I actually thought was fairly neat, but then this stopped being an option after .SD bindings got locked down.
I think we need to either allow the above .SD expression or have another alternative that can be written/read in a similar manner, from left to right, without having to skip back to the beginning of the sentence.
The text was updated successfully, but these errors were encountered:
.SD is allocated just once with the length of the maximum group, to avoid creating it again and again for each group. So I wouldn't opt for unlocking the binding, as it could lead to pretty nasty-to-track bugs.
It's not clear to me from the example why we need to set the key here.
I found myself doing the messy mid-line setkey much more before on was an option; is this still a necessary feature? I'm struggling to think of an example where it's necessary, maybe something like:
If one tries to set the key on an intermediate expression before continuing, the flow breaks down, as the setkey has to be in front and the whole thing becomes a mess. Here's a random example (that doesn't do anything, and can be done differently, but imagine more complex stuff instead, e.g. http://stackoverflow.com/a/25628423/817778) of what I have in mind:
For a short period of time someone pointed out (I forget who, sorry) that it can be done like so:
which I actually thought was fairly neat, but then this stopped being an option after .SD bindings got locked down.
I think we need to either allow the above .SD expression or have another alternative that can be written/read in a similar manner, from left to right, without having to skip back to the beginning of the sentence.
The text was updated successfully, but these errors were encountered: