Description Usage Arguments Examples
Return a vector or martrix(in row) of the nearest sites to a target.
1 2 3 4 5 6 7 8 9 10 |
h |
Matrix of distance or a distance object |
n |
Numbers of neighbors |
ii |
Index of the target site |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | xcoord <- replicate(2,runif(50))
xdis <- as.matrix(dist(xcoord))
nearest(1,10,xdis)
nearest(xdis,10)
## if you wanted the indices only
t(apply(nearest(xdis,10),2,which))
## if the target is included in the distance, but not wanted
nearest(1,10,xdis, rm.target = TRUE)
nearest(xdis[1:5,1:5],3, rm.target = TRUE)
## idem ii = 0 implies that the target is zero distance
nearest(0, 20, xdis[2,])
nearest(2, 20, xdis)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.