[datatable-help] Is the (re-)sorting of a data.table by setting its key stable?

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon May 3 02:34:45 CEST 2010


Hi all,

Firstly, thanks for fixing the bug regarding the non-resorting of a
data.table when it was transformed from a pre-existing data.table. I
just checked out the latest code from SVN and it seems to work as
expected.

Now on to the question:

Say I have a data.frame `gene.annos` like so:

      symbol  exon.start   exon.width   exon.anno
      WASH5P        4225          468         utr
      WASH5P        4833           69         utr
      WASH5P        5659          152         utr
LOC100288778        4225          468         utr
LOC100288778        4833           69         utr
LOC100288778        5659          152         utr
     FAM138F       24475          563         utr
     FAM138F       25140          205         utr
     FAM138F       25584          361         utr

Now say I create a new data.table from the data.frame, and set the
data.table's key to "symbol".

Is it guaranteed for the rows in each "subgroup" be moved around in
the same order as they appeared originally?

For instance, if I did that on this data.table, the information for
"FAM13AF" would be pushed to the top, but would the 1st, 2nd, and 3rd
rows for FAM13AF in the new data.table be the same 1st, 2nd, and 3rd
rows for FAM13AF in the original data.frame?

It looks like it's keeping them in order, but I just wanted to be sure
that this behavior is a guarantee by design, and not a happy
coincidence for now.

Thanks,
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact


More information about the datatable-help mailing list