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

Steve Lianoglou lianoglou.steve at gene.com
Fri Nov 22 15:45:20 CET 2013


Hi Daniel,

On Fri, Nov 22, 2013 at 6:15 AM, daniel.krizian
<daniel.krizian at gmail.com> wrote:
> 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?

The key is retained for me when I run your code:

R> key(DT[,list(a,b)])
[1] "a" "b"

What version of data.table are you using?

-steve

-- 
Steve Lianoglou
Computational Biologist
Genentech


More information about the datatable-help mailing list