[Rd] sort() and attributes

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Oct 18 09:03:51 CEST 2005


After the discussion a while back about how sort inconsistently handles 
attributes such as dim's, I have taken a closer look and found yet more 
anomalies.

That suggested trying out the principle that sort() should preserve only 
names (and sort those).  Now, sort(partial=) was preserving names and NOT 
sorting them, and since it was included for efficiency I decided it should 
just drop names.

One consequence of this is that sort() would drop S3 classes (which is 
necessary for e.g. time-series-like classes).

I have tested this out over CRAN packages and it is currently live in 
R-devel.  The only thing I can see it breaks is lattice (sorry Deepayan, 
please take a look at the changes made to axis.Date whose code you 
borrowed).

Given that this is close to what S does and sort() was not documented to 
preserve attributes, I was not expecting much impact from this change. 
Since it seems to have minimal impact this seems the best way forward, but 
I am open to counter-proposals.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list