setDT remove names attribute from input vector, that should not happen.
x = c(a = 4, b = 5)
setDT(list(c = x))[]
names(x)
Related
https://github.com/Rdatatable/data.table/issues/2487
https://github.com/Rdatatable/data.table/issues/1916
https://github.com/Rdatatable/data.table/issues/1244
https://github.com/Rdatatable/data.table/issues/683
A related bug:
setDT even modifies the input vector if the data.table is modified later on
see here
a <- 1:2 / 2
x <- 1:10 / 2
y <- 11/2
dt <- data.frame(a, x, y)
setDT(dt)
dt[ , cond := a == 1]
dt[(cond), c("x", "y") := list(y, x)]
x
#[1] 0.5 5.5 1.5 5.5 2.5 5.5 3.5 5.5 4.5 5.5
@BenoitLondon your issue is slightly different.. I've answered your SO post.