# load package library(randomForest) % set working directory setwd("/Users/ekremkocaguneli/Documents/ekrem/Lessons/STAT745/Project2/Data") # load dataset mydata <- read.table("boston-housing.data",header=TRUE) # first find the distance matrix of the dataset distanceMatrix = dist(mydata, method = "euclidean", diag = FALSE, upper = FALSE, p = 2) distanceMatrix = is.matrix(distanceMatrix) # apply ranking #asdf = cmdscale(distanceMatrix, k = 2, eig = TRUE, add = FALSE, x.ret = TRUE) loc <- cmdscale(distanceMatrix,k=2, add = FALSE, eig = TRUE, x.ret = FALSE) loc = as.matrix(loc) cmdsE <- cmdscale(distanceMatrix, k=2, add = TRUE, eig = TRUE, x.ret = TRUE) asdf=cmdsE$points x <- asdf[,1] y <- -asdf[,2] plot(x, y, type="n", xlab="", ylab="", main="2Dimensional Data via MDS") text(x, y, rownames(asdf), cex=0.8)