We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Was trying to swap values from a column into another column and erase the original values; I made a mistake in doing so:
set.seed(20349) DT = data.table( a = rnorm(10) ) DT[a < 0, c('a', 'b') := .(NULL, a)]
Which correctly errors:
Error in [.data.table(DT, a < 0, :=(c("a", "b"), .(NULL, a))) : When deleting columns, i should not be provided
[.data.table
:=
However, now DT is corrupted:
DT
DT # a b # 1: 0.6667242 NULL # 2: -1.8261938 NULL # 3: 0.2047286 NULL # 4: -0.4425548 NULL # 5: -0.6238520 NULL # 6: -1.9680856 NULL # 7: 0.2002663 NULL # 8: -0.1607745 NULL # 9: 0.0206196 NULL # 10: 0.3074775 NULL DT$b # NULL DT[is.na(b)]
Error in [.data.table(DT, is.na(b)) : SETLENGTH() can only be applied to a standard vector, not a 'NULL'
DT[ , b := NULL]
Error in ans[[target]] : subscript out of bounds
Seems the only way to clean the table is with a copy:
DT = DT[ , !'b']
Obviously what I tried is wrong (I meant to have .(NA, a) on the RHS), but it seems this mistake has cascaded...
.(NA, a)
The text was updated successfully, but these errors were encountered:
You can also remove it using DT[["b"]] <- NULL (which also makes a copy). Also DT[1] crashes my R session. Interesting edge case
DT[["b"]] <- NULL
DT[1]
Sorry, something went wrong.
In case it helps, set seems to work:
set
packageVersion("data.table") # [1] ‘1.11.8’ set(DT, j = "b", value = NULL) str(DT) # Classes ‘data.table’ and 'data.frame': 10 obs. of 1 variable: # $ a: num 0.667 -1.826 0.205 -0.443 -0.624 ... # - attr(*, ".internal.selfref")=<externalptr>
No branches or pull requests
Was trying to swap values from a column into another column and erase the original values; I made a mistake in doing so:
Which correctly errors:
However, now
DT
is corrupted:Seems the only way to clean the table is with a copy:
Obviously what I tried is wrong (I meant to have
.(NA, a)
on the RHS), but it seems this mistake has cascaded...The text was updated successfully, but these errors were encountered: