duplicated               package:base               R Documentation

_D_e_t_e_r_m_i_n_e _D_u_p_l_i_c_a_t_e _E_l_e_m_e_n_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Determines which elements of a vector are duplicates of elements
     with smaller subscripts, and returns a logical vector indicating
     which elements are duplicates.

_U_s_a_g_e:

     duplicated(x, incomparables = FALSE)

_A_r_g_u_m_e_n_t_s:

       x: an atomic vector

incomparables: a vector of values that cannot be compared. Currently,
          `FALSE' is the only possible value, meaning that all values
          can be compared.

_S_e_e _A_l_s_o:

     `unique'.

_E_x_a_m_p_l_e_s:

     x <- c(9:20, 1:5, 3:7, 0:8)
     ## extract unique elements
     (xu <- x[!duplicated(x)])
     stopifnot(xu == unique(x), # but unique(x) is more efficient
               0:20 == sort(x[!duplicated(x)]))

