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
DT = data.table(a = rep(4:1, 1:4), v = rnorm(10))
setkey(DT, a)
setorder(DT, a, v)
key(DT)
# NULL
Obviously DT is still sorted by a after setorder; that's why the second setkey here only runs setattr (btw, we should report this is happening if verbose = TRUE)
DT = data.table(a = rep(4:1, 1:4), v = rnorm(10))
setkey(DT, a, v)
setkey(DT, a, verbose = TRUE)
The note in the code is:
if forderv is not 0-length, it means order has changed. So, set key to NULL, else retain key.
So I guess it could be a conceptual question -- do we reset the key if the order has changed but the table is still sorted by the stated key?
This is particularly odd if I want to sort the last column in decreasing order. Is there any have DT keyed by a but guaranteed v is in decreasing order within a?
The text was updated successfully, but these errors were encountered:
Obviously
DT
is still sorted bya
aftersetorder
; that's why the secondsetkey
here only runssetattr
(btw, we should report this is happening ifverbose = TRUE
)The note in the code is:
So I guess it could be a conceptual question -- do we reset the key if the order has changed but the table is still sorted by the stated key?
This is particularly odd if I want to sort the last column in decreasing order. Is there any have
DT
keyed bya
but guaranteedv
is in decreasing order withina
?The text was updated successfully, but these errors were encountered: