Re: [Rd] Proposal unary - operator for factors

From: Hadley Wickham <>
Date: Wed, 03 Feb 2010 18:20:47 -0600

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




______________________________________________ mailing list
Received on Thu 04 Feb 2010 - 00:23:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 04 Feb 2010 - 04:30:19 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive