matchpt               package:Biobase               R Documentation

_N_e_a_r_e_s_t _n_e_i_g_h_b_o_r _s_e_a_r_c_h.

_D_e_s_c_r_i_p_t_i_o_n:

     Find the nearest neighbors of a set of query points in the same or
     another set of points in an n-dimensional real vector space, using
     the Euclidean distance.

_U_s_a_g_e:

         matchpt(x, y)

_A_r_g_u_m_e_n_t_s:

       x: A matrix (or vector) of coordinates. Each row represents a
          point in an 'ncol(x)'-dimensional real vector space.

       y: Optional, matrix (or vector) with the same number of columns
          as 'x'.

_D_e_t_a_i_l_s:

     If 'y' is provided, the function searches for each point in 'x'
     its nearest neighbor in 'y'. If 'y' is missing, it searches for
     each point in 'x' its nearest neighbor in 'x', excluding that
     point itself. In the case of ties, only the neighbor with the
     smaller index is given.

     The implementation is simple and of complexity 'nrow(x)' times
     'nrow(y)'. For larger problems, please consider one of the many
     more efficient nearest neighbor search algorithms.

_V_a_l_u_e:

     A 'data.frame' with two columns and 'nrow(x)' rows. The first
     column is the index of the nearest neighbor, the second column the
     distance to the nearest neighbor. If 'y' was given, the index is a
     row number in 'y', otherwise, in 'x'. The row names of the result
     are those of 'x'.

_A_u_t_h_o_r(_s):

     Oleg Sklyar osklyar@ebi.ac.uk

_E_x_a_m_p_l_e_s:

         a <- matrix(c(2,2,3,5,1,8,-1,4,5,6), ncol=2L, nrow=5L)
         rownames(a) = LETTERS[seq_len(nrow(a))]
         matchpt(a)
         b <- c(1,2,4,5,6)
         d <- c(5.3, 3.2, 8.9, 1.3, 5.6, -6, 4.45, 3.32)
         matchpt(b, d)
         matchpt(d, b)

