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

Daniel Krizian daniel.krizian at gmail.com
Fri Nov 22 17:32:26 CET 2013


Hello Steve and thanks for your reply. I am running data.table_1.8.11

Full details below:

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C

[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] timeDate_3010.98           data.table_1.8.11          quantstrat_0.7.8

 [4] foreach_1.4.1              blotter_0.8.15
PerformanceAnalytics_1.1.1
 [7] FinancialInstrument_1.1    quantmod_0.4-0             Defaults_1.1-1

[10] TTR_0.22-0                 xts_0.9-5                  zoo_1.7-10


loaded via a namespace (and not attached):
[1] codetools_0.2-8 grid_3.0.2      iterators_1.0.6 lattice_0.20-23
plyr_1.8
[6] reshape2_1.2.2  stringr_0.6.2   tools_3.0.2


On Fri, Nov 22, 2013 at 2:45 PM, Steve Lianoglou
<lianoglou.steve at gene.com>wrote:

> 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
>



-- 
*____________________________*
*Daniel Krizian, CFA, CAIA*
T: +44 74 5372 1101
M: daniel.krizian at gmail.com
uk.linkedin.com/in/danielkrizian
B: quantology.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20131122/f3da88b6/attachment.html>


More information about the datatable-help mailing list