I am using rank(a, ties.method="max") to rank a. But I am not quite sure what does ties.method="max" do. Can you please help?


Ties.method specifies the method rank uses to break ties. Suppose you have a vector c(1,2,3,3,4,5). It's obvious that 1 is first, and 2 is second. However, it's not clear what ranks should be assigned to the first and second 3s. Ties.method determines how this is done. There are a few options:

  • average assigns each tied element the "average" rank. The ranks would therefore be 1, 2, 3.5, 3.5, 5, 6
  • first lets the "earlier" entry "win", so the ranks are in numerical order (1,2,3,4,5,6)

  • min assigns every tied element to the lowest rank, so you get 1,2,3,3,5,6

  • max does the opposite: tied elements get the highest rank (1,2,4,4,5,6)

  • random breaks ties randomly, so you'd get either (1,2,3,4,5,6) or (1,2,4,3,5,6).

  • $\begingroup$ Thank you very much! Your answer helped me solve my problem! Thank you again! $\endgroup$ – Joy Aug 9 '12 at 18:24
  • 2
    $\begingroup$ No problem. You may already know this, but ?command will print the help for a command. $\endgroup$ – Matt Krause Aug 12 '12 at 3:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.