Skip to content
Prev 10486 / 63421 Next

rank(*) with NAs -- new option "keep" desired

I could have used this also.  Currently I do this:

z <- ifelse(is.na(y),NA,rank(y))
names(z) <- names(y)

The following also works but is less transparent:

z <- y
z[z==z] <- rank(y)

Another extension of rank that could be useful would be to have
an argument that causes it NOT to do tie averaging.  This is useful
when you are using rank(x) in the sense of an inverse permutation.
Currently I do this:

z <- order(order(y))
names(z) <- names(y)
--- Martin Maechler <maechler@stat.math.ethz.ch> wrote: