r - Remove multiple columns from data.table -


what's correct way remove multiple columns data.table? i'm using code below, getting unexpected behavior when accidentally repeated 1 of column names. wasn't sure if bug, or if shouldn't removing columns 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" 

this looks solid, reproducible bug. it's been filed bug #2791.

it appears repeating column attempts delete subsequent columns.
if no columns remain, r crashes.


update : fixed in v1.8.11. news :

assigning same column twice in same query error rather crash in circumstances; e.g., dt[,c("b","b"):=null] (delete reference same column twice). ricardo (#2751) , matt_k (#2791) reporting. tests added.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -