What is the correct way to delete multiple columns from data.table? I am currently using the code below, but was getting unexpected behavior when I accidentally repeated one of the column names. I was not sure if this was a mistake, or if I should not delete the columns this way.
library(data.table) DT <- data.table(x = letters, y = letters, z = letters) DT[ ,c("x","y") := NULL] names(DT) [1] "z"
The above works fine, but
DT <- data.table(x = letters, y = letters, z = letters) DT[ ,c("x","x") := NULL] names(DT) [1] "z"
r data.table
matt_k May 19 '13 at 19:16 2013-05-19 19:16
source share