Last chance! 50% off unlimited learning
Sale ends in
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)
knearneigh
region.id
, default seq(1, nrow(x))
nb
with a list of integer vectors containing neighbour region number ids.knearneigh
example(columbus)
coords <- coordinates(columbus)
col.knn <- knearneigh(coords, k=4)
plot(columbus, border="grey")
plot(knn2nb(col.knn), coords, add=TRUE)
title(main="K nearest neighbours, k = 4")
Run the code above in your browser using DataLab