knn2nb {spdep} | R Documentation |
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.
knn2nb(knn, row.names = NULL, sym = FALSE)
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 |
The function returns an object of class nb
with a list of integer vectors containing neighbour region number ids.
Roger Bivand Roger.Bivand@nhh.no
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")