### help file for hreorder()
### load ape library
library(ape)
data(bird.orders)
### convert the bird.orders to class hclust
bird.hclust <- as.hclust(multi2di(bird.orders))
### ready to draw tree/dendrograms
par(mfrow = c(1,3))
### plot phylogenetic tress
plot(bird.orders, direction = "downwards", cex = 1.5)
### the wrong results, because of the unordered height in hclust
### plot the bird.hclust
plot(bird.hclust, hang = -1 )
### add rectangles to the plot
rect.hclust(bird.hclust, k = 4)
### the proper results.
### reorder the hclust object
bird.hclust.ordered <- hcreorder(bird.hclust)
### plot the reordered hclust object
plot(bird.hclust.ordered, hang = -1 )
### add rectangles to the plot
rect.hclust(bird.hclust.ordered, k = 4)
### call cutree to divide the taxon to groups/clades
cutree(bird.hclust.ordered, k = 4)
## Not run
Run the code above in your browser using DataLab