Created
February 8, 2012 09:45
-
-
Save rukku/1767479 to your computer and use it in GitHub Desktop.
Gets the second nearest neighbor using spatstat's crossdist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get pairwise distances from rp and ponderosa datasets | |
xpairs <- crossdist(rp, ponderosa) | |
#Initialize vector container for X.2 | |
X.2 = numeric() | |
#Sort rows and get second nearest neighbor | |
for (i in 1:nrow(xpairs) { | |
x <- sort(xpairs[i,])[2] | |
X.2 <- append(X.2, x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment