Created
September 18, 2012 04:45
-
-
Save jstray/3741305 to your computer and use it in GitHub Desktop.
Apply multi-dimensional scaling to House of Lords voting history distance matrix, and plot
This file contains hidden or 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
# -------------------------------- MDS plot ------------------------------ | |
fit <- cmdscale(d,eig=TRUE, k=2) # k is the number of dim | |
x <- fit$points[,1] | |
y <- fit$points[,2] | |
# ]plot with colors corresponding to party | |
parties = factor(row.names(recentvotes)) | |
plot(x, y, xlab="Coordinate 1", ylab="Coordinate 2", main="House of Lords voting", pch=19, col=parties) | |
legend('topright', legend = levels(parties), col=palette(), cex = 0.8, pch = 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment