[Rd] Proposal unary - operator for factors

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 4 05:34:18 CET 2010


On Wed, 3 Feb 2010, Duncan Murdoch wrote:

> On 03/02/2010 7:20 PM, Hadley Wickham wrote:
>>>> Currently, for numeric a you can do either
>>>>   order(-a)
>>>> or
>>>>   order(a, decreasing=FALSE)
>>>> For nonnumeric types like POSIXct and factors only
>>>> the latter works.
>>>> 
>>>> Under my proposal your
>>>>   order(a, -b, c, d)
>>>> would be
>>>>   order(a, b, c, d, decreasing=c(FALSE,TRUE,FALSE,TRUE))
>>>> and it would work for any ordably class without modifications
>>>> to any classes.
>>> Why not use
>>>
>>>  order(a, -xtfrm(b), c, -xtfrm(d))
>> 
>> That's a good suggestion.  You could make it even easier to read with
>> desc <- function(x) -xtfrm(x)
>> 
>> order(a, desc(b), c, desc(d))
>> 
>> Could you remind me what xtfrm stands for?
>
> No, I don't think I ever worked it out. :-)

The same logic as strxfrm.

>
> Duncan Murdoch
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

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