sort-methods             package:memisc             R Documentation

_C_o_n_v_e_n_i_e_n_c_e _M_e_t_h_o_d_s _t_o _S_o_r_t _D_a_t_a _F_r_a_m_e_s _a_n_d _D_a_t_a _S_e_t_s

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

     The methods below return a sorted version of the data frame or
     data set, given as first argument.

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

     ## S3 method for class 'data.frame':
     sort(x,decreasing=FALSE,by=NULL,na.last=NA,...)
     ## S3 method for class 'data.set':
     sort(x,decreasing=FALSE,by=NULL,na.last=NA,...)

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

       x: a data frame or data set.

decreasing: a logical value, should sorting be in increasing or
          decreasing order?

      by: a character name of variable names, by which to sort; a
          formula giving the variables, by which to sort; NULL, in
          which case, the data frame / data set is sorted by all of its
          variables. 

 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

     ...: other arguments, currently ignored.

_V_a_l_u_e:

     A sorted copy of 'x'.

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

     DF <- data.frame(
             a = sample(1:2,size=20,replace=TRUE),
             b = sample(1:4,size=20,replace=TRUE))
     sort(DF)
     sort(DF,by=~a+b)
     sort(DF,by=~b+a)
     sort(DF,by=c("b","a"))
     sort(DF,by=c("a","b"))

