dist2               package:flexclust               R Documentation

_C_o_m_p_u_t_e _p_a_i_r_w_i_s_e _d_i_s_t_a_n_c_e_s _b_e_t_w_e_e_n _t_w_o _d_a_t_a _s_e_t_s

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

     This function computes and returns the distance matrix computed by
     using the specified distance measure to compute the pairwise
     distances between the rows of two data matrices.

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

     dist2(x, y, method = "euclidean", p=2)

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

       x: A data matrix.

       y: A vector or second data matrix.

  method: the distance measure to be used. This must be one of
          '"euclidean"', '"maximum"', '"manhattan"', '"canberra"',
          '"binary"' or '"minkowski"'. Any unambiguous substring can be
          given.

       p: The power of the Minkowski distance.

_D_e_t_a_i_l_s:

     This is a two-data-set equivalent of the standard function 'dist'.
     It returns a matrix of all pairwise distances between rows in 'x'
     and 'y'. The current implementation is efficient only if 'y' has
     not too many rows (the code is vectorized in 'x' but not in 'y').

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

     Friedrich Leisch

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

     'dist'

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

     x = matrix(rnorm(20), ncol=4)
     rownames(x) = paste("X", 1:nrow(x), sep=".")
     y = matrix(rnorm(12), ncol=4)
     rownames(y) = paste("Y", 1:nrow(y), sep=".")

     dist2(x, y)
     dist2(x, y, "man")

     data(milk)
     dist2(milk[1:5,], milk[4:6,])

