library(ape)
library(stats) # for hclust and example data set
# create hclust object
data(USArrests)
hclust.tree<-hclust(dist(USArrests[1:6,]))
plot(hclust.tree)
# convert into phylo object
phylo.tree <- as.phylo(hclust.tree)
phylo.tree
plot(phylo.tree)
# phylogenetic tree is ultrametric and binary
is.ultrametric(phylo.tree)
is.binary.tree(phylo.tree)
# convert back into hclust object
converted.tree <- as.hclust(phylo.tree)
plot(converted.tree)
Run the code above in your browser using DataLab