Skip to content

Instantly share code, notes, and snippets.

@drewlanenga
Last active August 29, 2015 14:25
Show Gist options
  • Save drewlanenga/2cb189faa476b5f45cea to your computer and use it in GitHub Desktop.
Save drewlanenga/2cb189faa476b5f45cea to your computer and use it in GitHub Desktop.
R Example: Distance Between European Cities using Multidimensional Scaling
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