rank                  package:base                  R Documentation

_S_a_m_p_l_e _R_a_n_k_s

_D_e_s_c_r_i_p_t_i_o_n:

     Returns the sample ranks of the values in a numeric vector. Ties
     result in ranks being averaged.

_U_s_a_g_e:

     rank(x, na.last = TRUE)

_A_r_g_u_m_e_n_t_s:

       x: a numeric vector.

 na.last: for controlling the treatment of `NA's. If `TRUE', missing
          values in the data are put last; if `FALSE', they are put
          first; if `NA', they are removed.

_S_e_e _A_l_s_o:

     `order' and `sort'.

_E_x_a_m_p_l_e_s:

     (r1 <- rank(x1 <- c(3,1,4,59,26)))
     (r2 <- rank(x2 <- c(3,1,4,5,9,2,6,5,3,5))) # ties

     ## rank() is "idempotent": rank(rank(x)) == rank(x) :
     stopifnot(rank(r1) == r1, rank(r2) == r2)

