[datatable-help] Key dropped when DT[, list(a, b)]

daniel.krizian daniel.krizian at gmail.com
Fri Nov 22 15:15:37 CET 2013


Hello, I have:

DT <- data.table(a=1:10, b=1:10,c=1:10, key=c("a","b"))
key(DT) # [1] "a" "b"
key(DT[,list(a,b)]) # NULL

Note that DT loses its key when I select a subset of columns like above.

Is this a (known) bug/ expected result?

Maybe it is just me, but I would expect the data.table to retain its key in
the SELECT-like operation, otherwise it causes me to repeatedly call
(expensive) setkey(), when in fact I am not changing the structure of
rows/indices significantly.

Thanks,
Daniel



--
View this message in context: http://r.789695.n4.nabble.com/Key-dropped-when-DT-list-a-b-tp4680965.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list