On Aug 25, 2011, at 7:56 AM, Sebastian Bauer wrote:

Hi!

On 08/24/2011 07:46 PM, David Winsemius wrote:
I was looking for an elegant solution ;) In the real case I have double
values and this would be quite inefficient then.

Still no r-code:

Then what about rank(order(...) , further-ties.method-argument) ?

I think that, as order() always gives a different value for each element, rank(order()) would return the same result as order() alone.

Quite right. I didn't test it since there was no example provided. Do you not understand what is meant by a reproducible example.

Pretty much every solution I come up with leaves me (re-) asking the question: What's wrong with rank(paste(...))?

Here's another possibility:

> rr <- data.frame(a = c(1,1,1,1,2), b=c(1,2,2,3,1))

> ave(order(rr$a, rr$b), rr$a, rr$b )
[1] 1.0 2.5 2.5 4.0 5.0


Bye,
Sebastian

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to