Cluster.R

From Organic Design wiki
Revision as of 20:51, 11 November 2006 by Sven (talk | contribs) (bugs)

clusterPlot <- function(x, dmethod = "euclidian", hmethod="complete", ...) {

 oldpar <- par(mfrow=c(2,1))  
 xDist <- dist(x, method=dmethod)
 
  1. 1) Tree dendrogram
 xClust <- hclust(xDist, method=hmethod)
 plclust(xClust)
 
  1. 2) Image plot...
 image(x = 1:nrow(x), y = 1:ncol(x), z = x[xClust$order, ])
 par(oldpar)
 invisible()

}

  1. Test

x <- matrix(rnorm(40), nc=4) clusterPlot(x)