knn2nb                 package:spdep                 R Documentation

_N_e_i_g_h_b_o_u_r_s _l_i_s_t _f_r_o_m _k_n_n _o_b_j_e_c_t

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

     The function converts a 'knn' object returned by 'knearneigh' 
     into a neighbours list of class 'nb' with a list of integer
     vectors  containing neighbour region number ids.

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

     knn2nb(knn, row.names = NULL, sym = FALSE)

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

     knn: A knn object returned by 'knearneigh'

row.names: character vector of region ids to be added to the neighbours
          list as attribute 'region.id', default 'seq(1, nrow(x))'

     sym: force the output neighbours list to symmetry

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

     The function returns an object of class 'nb' with a list of
     integer vectors containing neighbour region number ids.

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

     Roger Bivand Roger.Bivand@nhh.no

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

     'knearneigh'

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

     data(columbus)
     col.knn <- knearneigh(coords, k=4)
     library(maptools)
     plot(polys, border="grey", forcefill=FALSE)
     plot(knn2nb(col.knn), coords, add=TRUE)
     title(main="K nearest neighbours, k = 4")

