From murdoch at stats.uwo.ca  Thu Feb  4 01:16:44 2010
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed, 03 Feb 2010 19:16:44 -0500
Subject: [Rd] Proposal unary - operator for factors
In-Reply-To: <77EB52C6DD32BA4D87471DCD70C8D7000275B165@NA-PA-VBE03.na.tibco.com>
References: <f8e6ff051002031510m4dca3c8co8d69c3117e1deab4@mail.gmail.com>	<77EB52C6DD32BA4D87471DCD70C8D7000275B14F@NA-PA-VBE03.na.tibco.com>	<f8e6ff051002031538ub5c2892ya83806ad3fe025a0@mail.gmail.com>
	<77EB52C6DD32BA4D87471DCD70C8D7000275B165@NA-PA-VBE03.na.tibco.com>
Message-ID: <4B6A11EC.7040606@stats.uwo.ca>

On 03/02/2010 6:49 PM, William Dunlap wrote:
>> -----Original Message-----
>> From: h.wickham at gmail.com [mailto:h.wickham at gmail.com] On 
>> Behalf Of Hadley Wickham
>> Sent: Wednesday, February 03, 2010 3:38 PM
>> To: William Dunlap
>> Cc: r-devel at r-project.org
>> Subject: Re: [Rd] Proposal unary - operator for factors
>>
>>> It wouldn't make sense in the context of
>>>   vector[-factor]
>> True, but that doesn't work currently so you wouldn't lose anything.
>> However, it would make a certain class of problem that used to throw
>> errors become silent.
>>
>>> Wouldn't it be better to allow order's decreasing argument
>>> to be a vector with one element per ... argument?  That
>>> would work for numbers, factors, dates, and anything
>>> else.  Currently order silently ignores decreasing[2] and
>>> beyond.
>> The problem is you might want to do something like order(a, -b, c, -d)
> 
> 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))

??

Duncan Murdoch



[Rd] Proposal unary - operator for factors
Duncan Murdoch