I tried to find a function or expression in Mathematica that produces the same output as the RANK
function in Excel (see its description here), but unfortunately I could not find an existing one.
For example consider the following list:
{29400., 28200., 22300., 20900., 20300., 19800., 17400., 16600., 16300., 16100., 15500., 15300., 15300., 15200., 15100., 14900.,14700., 14700., 14400., 13900.}
The RANK
function in Excel will produce:
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 14, 15, 16, 17, 17, 19, 20}
(* *) (* *)
Notice that ties are given the same rank and an appropriate number of ranks is skipped after that. I would like to reproduce that behavior.
In Mathematica, I used the following expression :
m = q /. Thread[# -> Ordering[#, All, Greater]] & @ Union@q
However, the output is different:
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 13, 14, 15, 16, 16, 17, 18, 18, 19, 20}
Any suggestions on how to implement the desired behavior?
ArrayComponents
. $\endgroup$ArrayComponents
, but subtly different $\endgroup$