Last active
August 29, 2015 14:25
-
-
Save drewlanenga/2cb189faa476b5f45cea to your computer and use it in GitHub Desktop.
R Example: Distance Between European Cities using Multidimensional Scaling
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
require(graphics) | |
loc <- cmdscale(eurodist) | |
x <- loc[, 1] | |
y <- -loc[, 2] # reflect so North is at the top | |
## note asp = 1, to ensure Euclidean distances are represented correctly | |
plot(x, y, type = "n", xlab = "", ylab = "", asp = 1, axes = FALSE, main = "cmdscale(eurodist)") | |
text(x, y, rownames(loc), cex = 0.6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment