#install.packages("smacof") require("smacof") data("ekman") ekman.d <- sim2diss(ekman, method = 1) library(MASS) par(mfrow = c(1, 2)) ekman.mds <- isoMDS(ekman.d, k = 2) plot(ekman.mds$points, type = "n", xlab="Coordinate 1", ylab="Coordinate 2", main="Non-metric MDS") text(ekman.mds$points, labels = rownames(ekman.mds$points), cex=.7) fit <- cmdscale(ekman.d,eig=TRUE, k=2) # k is the number of dim fit # view results # plot solution plot( fit$points, type = "n", xlab="Coordinate 1", ylab="Coordinate 2", main="Metric MDS") text(fit$points, labels = rownames(ekman.mds$points), cex=.7) ## 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)