powered by
Counts the number of nodes in a tree (dendrogram, hclust, phylo).
nnodes(x, ...)# S3 method for default nnodes(x, ...)# S3 method for dendrogram nnodes(x, ...)# S3 method for hclust nnodes(x, ...)# S3 method for phylo nnodes(x, ...)
# S3 method for default nnodes(x, ...)
# S3 method for dendrogram nnodes(x, ...)
# S3 method for hclust nnodes(x, ...)
# S3 method for phylo nnodes(x, ...)
tree object (dendrogram or hclust)
not used
The number of leaves in the tree
The idea for the name is from functions like ncol, and nrow.
The phylo method is based on turning the phylo to hclust and than to dendrogram. It may not work for complex phylo trees.
nrow, count_terminal_nodes, nleaves
# NOT RUN { hc <- hclust(dist(USArrests[1:5, ]), "ave") dend <- as.dendrogram(hc) nnodes(dend) # 9 nnodes(hc) # 9 # }
Run the code above in your browser using DataLab