nn | R Documentation |
Given the locations of different objects, this function determines the identity of the nearest neighboring object to each object.
nn(x, y, id, geo = FALSE)
x |
A vector of x (or longitude) coordinates. |
y |
A vector of y (or latitude) coordinates. |
id |
A vector corresponding to the unique identities of each track. |
geo |
A logical value indicating whether the locations are defined by geographic coordinates (pairs of longitude/latitude values). Default: FALSE. |
A vector of the same length as x and y representing the identity of the nearest neighboring object to each object.
Simon Garnier, garnier@njit.edu
nnd
x <- rnorm(25)
y <- rnorm(25, sd = 3)
id <- 1:25
nn(x, y, id)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.