knn | R Documentation |
knn
returns the k nearest neighbors of the
n coordinates in coords
. The nearest neighbors
are constructed to be self-inclusive, i.e., an
observations is its closest neighbor.
knn(coords, longlat = FALSE, k = 1, d = NULL)
coords |
An n \times 2 matrix of centroid coordinates for the regions in the form (x, y) or (longitude, latitude) is using great circle distance. |
longlat |
The default is |
k |
An integer indicating the maximum number of regions to inclue in a potential cluster. Default is 10 |
d |
An n by n distance matrix. If provided,
this is used instead of computing |
An n \times k matrix of nearest neighbors.
data(nydf) coords <- nydf[, c("longitude", "latitude")] knn(coords, longlat = TRUE, k = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.