# R - Clustering and Multidimensional Scaling

I am trying to get to grips with Clustering and Visualisation.

I have a set of data (a matrix) that I want to cluster (using R) and then visualise (HTML5 Canvas).

So, I can use MDS to get the coordinates of a matrix, for example:

cells <- c(1, 1, 2, 1, 4, 3, 5, 4)
rnames <- c("A", "B", "C", "D")
cnames <- c("X", "Y")
x <- matrix(cells, nrow=4, ncol=2, byrow=TRUE, dimnames=list(rnames, cnames))
d <-dist(x)
m <- cmdscale(d,eig=TRUE, k=3)
m <- cmdscale(d,eig=TRUE, k=2)
print(m)


But, should I first cluster this data (using something like k-means) or should I cluster the output of MDS? Or can I just cluster (and get the coordinates using some other method) and ignore MDS?

What is the relationship between MDS and K-means, if any?

I am unsure what is the best way to approach?

Any suggestions?

Thanks,

s

• Why do you think you need MDS - your data matrix are already pairwise distances rather than original cases X variables? – ttnphns Jan 25 '12 at 15:01
• Thanks for the comment. I think this is what I am trying to figure out? So, if I cluster (suing kmeans for example) I should get a pairwise matrix in return, how do I access the coordinates (or points) of that matrix. This is probably a very rudimentary question but I just want to make sure I understand it correctly. Thanks again. – slotishtype Jan 25 '12 at 15:14