mixNamedVec             package:simecol             R Documentation

_M_i_x _T_w_o _N_a_m_e_d _V_e_c_t_o_r_s, _R_e_s_o_l_v_i_n_g _N_a_m_e _C_o_n_f_l_i_c_t_s

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

     The function mixes two named vectors. The resulting vectors
     contains all elements with unique name and only one of the two
     versions of the elements which have the same name in both vectors.

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

     mixNamedVec(x, y, resolve.conflicts = c("x", "y"), warn = TRUE)

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

       x: first named vector,

       y: second named vector,

resolve.conflicts: name of the vector from which all elements are
          taken,

    warn: an indicator if a warning should be given if elements are not
          unique. This argument should usually set to FALSE, but the
          default is TRUE to be on the safe side.

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

     a vector with all elements from one vector and only these elements
     of the second, that have a unique name not contained in the other
     vector.

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

     Thomas Petzoldt

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

     'which'

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

     x <- c(a=1, b=2, c=3)
     y <- c(a=1, b=3, d=3)

     mixNamedVec(x, y)
     mixNamedVec(x, y, resolve.conflicts="x")

     mixNamedVec(x, y, resolve.conflicts="x", warn=FALSE)
     mixNamedVec(x, y, resolve.conflicts="y", warn=FALSE)

     ## without names, returns vector named in "resolve conflicts"
     x <- as.vector(x)
     y <- as.vector(y)
     mixNamedVec(x, y)
     mixNamedVec(x, y, resolve.conflicts="y")

     ## names partly
     x <- c(4, a=1, b=2, c=3, 4, 9)
     y <- c(a=1, 6, b=3, d=3, 8)

     mixNamedVec(x, y)
     mixNamedVec(x, y, resolve.conflicts="y")

