From murdoch at stats.uwo.ca  Thu Feb  4 01:49:12 2010
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed, 03 Feb 2010 19:49:12 -0500
Subject: [Rd] Proposal unary - operator for factors
In-Reply-To: <f8e6ff051002031620t84ad1d6tb859ccd5825052fe@mail.gmail.com>
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>
Message-ID: <4B6A1988.4000600@stats.uwo.ca>

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. :-)

Duncan Murdoch



[Rd] Proposal unary - operator for factors
Duncan Murdoch