[R] rank() not doing really what I want
David Winsemius
dwinsemius at comcast.net
Fri Oct 12 18:01:43 CEST 2012
On Oct 12, 2012, at 1:07 AM, Henri-Paul Indiogine wrote:
> Hi Michael!
>
> 2012/10/12 R. Michael Weylandt <michael.weylandt at gmail.com>:
>> If they are already in decreasing order, you might be able to work
>> something out like (untested):
>>
>> cumsum(c(1, diff(x) < 0))
>
> Thanks seems to work. Thanks a bunch!
Another strategy:
cumsum(!duplicated(x))
--
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list