File:Dend12.png

From 太極
Jump to navigation Jump to search

Original file(876 × 448 pixels, file size: 11 KB, MIME type: image/png)

Summary

set.seed(123)
dat <- matrix(rnorm(20), ncol=2)

# perform hierarchical clustering
hc <- hclust(dist(dat))

# plot dendrogram
plot(hc)

# get ordering of leaves
ord <- order.dendrogram(as.dendrogram(hc))
ord
# [1]  8  3  6  5 10  1  9  7  2  4
# Same as seen on the dendrogram nodes

# Rotate the branches (1,9) & (7,2,4)
plot(rotate(hc, c("8", "3", "6", "5", "10", "7", "2", "4", "1", "9")), main="Rotated")
# OR move (8:10) in front of (6:7)
plot(rotate(hc, c(1,2,3,4,5,8:10,6:7)), main='Rotate2')

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current16:17, 12 August 2023Thumbnail for version as of 16:17, 12 August 2023876 × 448 (11 KB)Brb (talk | contribs){{Pre}} set.seed(123) dat <- matrix(rnorm(20), ncol=2) # perform hierarchical clustering hc <- hclust(dist(dat)) # plot dendrogram plot(hc) # get ordering of leaves ord <- order.dendrogram(as.dendrogram(hc)) ord # [1] 8 3 6 5 10 1 9 7 2 4 # Same as seen on the dendrogram nodes # Rotate the branches (1,9) & (7,2,4) plot(rotate(hc, c("8", "3", "6", "5", "10", "7", "2", "4", "1", "9")), main="Rotated") </pre>

The following page uses this file:

Metadata