[Rd] Proposal unary - operator for factors
hadley at rice.edu
Thu Feb 4 01:20:47 CET 2010
>> Currently, for numeric a you can do either
>> 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?
More information about the R-devel