Difference between revisions of "Cluster.R"
From Organic Design wiki
(bugs) |
m |
||
Line 5: | Line 5: | ||
# 1) Tree dendrogram | # 1) Tree dendrogram | ||
xClust <- hclust(xDist, method=hmethod) | xClust <- hclust(xDist, method=hmethod) | ||
− | plclust(xClust) | + | plclust(xClust, sub="") |
# 2) Image plot... | # 2) Image plot... | ||
Line 15: | Line 15: | ||
# Test | # Test | ||
x <- matrix(rnorm(40), nc=4) | x <- matrix(rnorm(40), nc=4) | ||
+ | colnames(x) <- LETTERS[1:4] | ||
+ | rownames(x) <- letters[1:10] | ||
clusterPlot(x) | clusterPlot(x) |
Revision as of 20:54, 11 November 2006
clusterPlot <- function(x, dmethod = "euclidian", hmethod="complete", ...) {
oldpar <- par(mfrow=c(2,1)) xDist <- dist(x, method=dmethod)
- 1) Tree dendrogram
xClust <- hclust(xDist, method=hmethod) plclust(xClust, sub="")
- 2) Image plot...
image(x = 1:nrow(x), y = 1:ncol(x), z = x[xClust$order, ]) par(oldpar) invisible()
}
- Test
x <- matrix(rnorm(40), nc=4) colnames(x) <- LETTERS[1:4] rownames(x) <- letters[1:10] clusterPlot(x)