# R-code for multidimensional scaling # The data set eurodist contains the road distances (in km) between # 21 cities in Europe. Based on these data, we can construct a map # of the location of the cities. Since the road distances do not correspond # exactly to geographical distances, the map is only approximately correct 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) # iris data loc <- cmdscale(dist(iris[,1:4])) x <- loc[,1] y <- loc[,2] plot(x, y, type="n", xlab="", ylab="", main="cmdscale(dist(iris))") text(x, y, c(1:150), col=c(rep("red",50), rep("blue",50), rep("orange",50)))