Skip to content

Instantly share code, notes, and snippets.

@gwerbin
Created July 25, 2014 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwerbin/275a5df837dabcf74dda to your computer and use it in GitHub Desktop.
Save gwerbin/275a5df837dabcf74dda to your computer and use it in GitHub Desktop.
PCA & MDS demo
require(spls)
require(MASS)
data(prostate)
pca <- prcomp(prostate$x)
plot(pca$x,main="Principal components mapping of Prostate data",xlab="Dim 1",ylab="dim 2")
plot(pca$x,main="Principal components mapping of Prostate data",xlab="Dim 1",ylab="dim 2",pch=prostate$y+1)
sam <- sammon(dist(prostate$x))
plot(sam$points,main="Sammon mapping of Prostate data",xlab="Dim 1",ylab="Dim 2",pch=prostate$y+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment