[datatable-help] key disappears after merge of data tables

Matthew Dowle mdowle at mdowle.plus.com
Thu Jan 6 11:40:58 CET 2011


If all is TRUE (or just all.x or all.y is TRUE) then result is keyed.

Why the key is not set when all is FALSE (default) I'm not sure.  Tom - can 
you remember?  Something to do with NAs in keys seems to ring a bell.

Matthew


"Joseph Voelkel" <jgvcqa at rit.edu> wrote in message 
news:70EFCDD908F9264785FA08EC3A47132016CC45F47C at ex02mail01.ad.rit.edu...
> See code below. When two data tables are merged (by their key 
> variable(s)), that key disappears in the resulting table. While this is 
> probably not strictly a bug, it would seem that the user would most likely 
> want to preserve the key in the output (especially if just enlarging the 
> original data table, e.g. dt2<-merge(dt1,dt2).)
>
>
>> dt1<-data.table(a=1:6,b=11:16,key="a")
>> dt2<-data.table(a=1:6,c=21:26,key="a")
>> dt3<-merge(dt1,dt2)
>>
>>
>     NAME NROW MB COLS  KEY
> [1,] dt1     6 1  a,b   a
> [2,] dt2     6 1  a,c   a
> [3,] dt3     6 1  a,b,c
> Total: 3MB
>
>
> Joseph G. Voelkel, Ph.D.
> Professor, Center for Quality and Applied Statistics
> Kate Gleason College of Engineering
> Rochester Institute of Technology
> V 585-475-2231
> F 585-475-5959
> joseph.voelkel at rit.edu 





More information about the datatable-help mailing list