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)

