nodeHeights {phytools} | R Documentation |
Compute the heights above the root of each node
Description
nodeHeights
computes the height above the root for all nodes in the tree. nodeheight
computes the height above the root for a single node.
Usage
nodeHeights(tree, ...)
nodeheight(tree, node, ...)
Arguments
tree |
a phylogeny as an object of class |
node |
for |
... |
optional arguments - presently only |
Details
The function nodeHeights
also gives a handy way to get the total length of the tree from the root to the highest tip which will be given by max(nodeHeights(tree))
.
Generally speaking, nodeHeights
will be faster if the heights of all or a large proportion of nodes is needed, whereas nodeheight
will be faster if the height of one or a small number of nodes are needed.
Value
Either a matrix of the same dimensions as tree$edge
containing the height above the root of each node in edge
(for nodeHeights
); or a single positive number (for nodeheight
).
Author(s)
Liam Revell liam.revell@umb.edu
References
Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). PeerJ, 12, e16505.
See Also
Examples
## load tree
data(vertebrate.tree)
## compute height of all nodes
H<-nodeHeights(vertebrate.tree)
print(H)
## compute total tree depth
max(H)