[R] Suspicious behaviour of sort on POSIXct vectors in R-2.3.0 and R-2.3.1

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jun 6 22:14:01 CEST 2006


On Tue, 6 Jun 2006, patrick.guevel at uk.bnpparibas.com wrote:

> Hi ,
>
> When I sort a vector of POSIXct values in R-2.3.0 and R-2.3.1, I get a
> vector of numeric values and this gets some of my code to crash (class
> object creation). Is that a R bug?

No, it is as documented: see ?sort

      As from R 2.3.0, all attributes are removed from the return value
      except names, which are sorted.  (If 'partial' is specified even
      the names are removed.)

Note, the class is an attribute.  For many classes sorting destroys the 
appropriateness of the class.

> In the mean time. I'll try to override the sort function for the POSIXct
> objects.

You can restore the class if appropriate.

-- 
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-help mailing list