uniqueL               package:sfsmisc               R Documentation

_A _R_e_v_e_r_s_a_b_l_e _V_e_r_s_i_o_n _o_f _u_n_i_q_u_e()

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

     A version of 'unique' keeping enough information to reverse (or
     _invert_) to the original data.

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

     uniqueL(x, isuniq = !duplicated(x))

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

       x: numeric vector, of length 'n', say.

  isuniq: logical vector of the same length as 'x'.  For the reversion
          to work this should select at least all unique values of 'x'.

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

     list of two components, 

      ix: integer vector of indices

      xU: vector of values from 'x'

     such that both 'x[isuniq] === xU' and 'xU[ix] === x'.

_A_u_t_h_o_r(_s):

     Martin Maechler

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

     'unique', 'duplicated'.

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

      x0 <- c(1:3,2:7,8:4)
      str(r0 <- uniqueL(x0))
      with(r0, xU[ix]) ## == x0 !

