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).