home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-I / help / base / order < prev    next >
Encoding:
Text File  |  1997-04-23  |  907 b   |  36 lines

  1.     
  2.     _O_r_d_e_r_i_n_g _P_e_r_m_u_t_a_t_i_o_n
  3.     
  4.          order(...)
  5.     
  6.     _A_r_g_u_m_e_n_t_s:
  7.     
  8.              ... : a sequence of vectors.
  9.     
  10.     _D_e_s_c_r_i_p_t_i_o_n:
  11.     
  12.          order returns a permutation which will rearrange its
  13.          first argument into ascending order.  In the case of
  14.          ties in the first vector, values in the second are used
  15.          to break the ties.  If the values are still tied,
  16.          values in the later arguments are used to break the
  17.          tie.
  18.     
  19.          NA values are treated as greater than any other values
  20.          so that permutations returned by order move NA values
  21.          to the top end of the array.
  22.     
  23.     _S_e_e _A_l_s_o:
  24.     
  25.          sort.
  26.     
  27.     _E_x_a_m_p_l_e_s:
  28.     
  29.          x <- c(5:1, 6:8, 12:9)
  30.          y <- (x - 5)^2
  31.          # rearrange matched vectors so that
  32.          # the first is in ascending order
  33.          o <- order(x)
  34.          rbind(x[o], y[o])
  35.     
  36.