Gabor Grothendieck writes:

> <White.Denis <at> epamail.epa.gov> writes:
> > SAS proc rank has ties options of high and low that would allow
> > rank (c(1,1,2,2,2,2,3)) == 1 1 3 3 3 3 7
> > Could R support these ties.methods?

> Don't know how SAS works but for your vector:
> 
> > z <- c(1,1,2,2,2,2,3)
> > match(z,z)
> [1] 1 1 3 3 3 3 7

Ah, but if z isn't presorted, then it worketh not:

E.g.

        > w <- c(2,2,2,1,3,1,2)
        > match(w,w)
        [1] 1 1 1 4 5 4 1

Try
        > bar <- function(x) {
                o <- order(x)
                x <- x[o]
                match(x,x)[order(o)]
         }

Then
        > bar(w)
        [1] 3 3 3 1 7 1 3

which ***is*** what's wanted.  I have not tested this idea any
further. :-)

                                cheers,

                                        Rolf Turner
                                        [EMAIL PROTECTED]

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to