From ripley at stats.ox.ac.uk  Thu Feb  4 05:34:18 2010
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 4 Feb 2010 04:34:18 +0000 (GMT)
Subject: [Rd] Proposal unary - operator for factors
In-Reply-To: <4B6A1988.4000600@stats.uwo.ca>
References: <f8e6ff051002031510m4dca3c8co8d69c3117e1deab4@mail.gmail.com>
	<77EB52C6DD32BA4D87471DCD70C8D7000275B14F@NA-PA-VBE03.na.tibco.com>
	<f8e6ff051002031538ub5c2892ya83806ad3fe025a0@mail.gmail.com>
	<77EB52C6DD32BA4D87471DCD70C8D7000275B165@NA-PA-VBE03.na.tibco.com>
	<4B6A11EC.7040606@stats.uwo.ca>
	<f8e6ff051002031620t84ad1d6tb859ccd5825052fe@mail.gmail.com>
	<4B6A1988.4000600@stats.uwo.ca>
Message-ID: <alpine.LFD.2.00.1002040433090.24305@gannet.stats.ox.ac.uk>

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



[Rd] Proposal unary - operator for factors
Prof Brian Ripley