Monday, October 25, 2010

R: Principal coordinates metric and non-metric scaling

# lib(s): labdsv

# Data input: generic

# - Principal coordinates metric scaling - (aka Classical (Metric) Multidimensional Scaling )

# This produces some shit:

the.dist <- dist(infile)
the.cmd <- cmdscale(the.dist)

# How about a plot?
x<- the.cmd[,1]
y<- the.cmd[,2]
plot(x,y) # what is the plot supposed to show anyway?!?

# - End of Principal coordinates metric scaling - (aka Classical (Metric) Multidimensional Scaling )

# - Principal coordinates non-metric scaling - (aka Nonmetric Multidimensional Scaling)

library(labdsv)
non-met <- nmds(the.dist)

# how about another plot?
plot(non-met)

# - End of Principal coordinates non-metric scaling - (aka Nonmetric Multidimensional Scaling)

# what actually happens in either of the above, however, remains a mystery to me.

# /* END OF PRINCIPAL COORDINATES METRIC/NON-METRIC SCALING */

No comments:

Post a Comment