Multidimensional Scaling
Purpose : To explore Multi dimensional scaling plot in R and draw
my very first Metric MDS and Non Metric MDS plots in my life.
> library(MASS) |
Metric MDS
> loc <- cmdscale(eurodist) > x <- loc[, 1] > y <- -loc[, 2] > plot(x, y, type = "n", xlab = "", ylab = "", main = "cmdscale(eurodist)") > text(x, y, rownames(loc), cex = 0.8) |
Non Metric MDS
> swiss.x <- as.matrix(swiss[, -1]) > swiss.dist <- dist(swiss.x) > swiss.mds <- isoMDS(swiss.dist) initial value 2.979731 iter 5 value 2.431486 iter 10 value 2.343353 final value 2.338839 converged > plot(swiss.mds$points, type = "n") > text(swiss.mds$points, labels = as.character(1:nrow(swiss.x))) |