set.seed(42)
coords <- cbind(x = runif(50), y = runif(50))
rownames(coords) <- paste0("spot_", 1:50)
# \donttest{
if (requireNamespace("RANN", quietly = TRUE)) {
W <- getSpatialNeighbors_KNN(coords, k = 6)
}
# }
Run the code above in your browser using DataLab