nnodes | R Documentation |
Counts the number of nodes in a tree (dendrogram, hclust, phylo).
nnodes(x, ...)
## Default S3 method:
nnodes(x, ...)
## S3 method for class 'dendrogram'
nnodes(x, ...)
## S3 method for class 'hclust'
nnodes(x, ...)
## S3 method for class 'phylo'
nnodes(x, ...)
x |
tree object (dendrogram or hclust) |
... |
not used |
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.
The number of leaves in the tree
nrow, count_terminal_nodes, nleaves
hc <- hclust(dist(USArrests[1:5, ]), "ave")
dend <- as.dendrogram(hc)
nnodes(dend) # 9
nnodes(hc) # 9
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.