Get the node numbers associated with tip- or node-labels in a tree

PCMTreeMatchLabels(tree, labels, stopIfNotFound = TRUE)

Arguments

tree

a phylo object

labels

a character vector with valid tip or node labels from tree

stopIfNotFound

logical indicating if an error should be raised in case a label has not been found in the tree labels. Default: TRUE

Value

an integer vector giving the tip- or node- integer indices corresponding to labels. If stopIfNotFound is set to FALSE, this vector may contain NAs for the labels that were not found.

Examples

set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion") PCMTreeMatchLabels(PCMTree(ape::rtree(20)), c("t1", "t15", "21", "39"))
#> [1] 16 6 21 39
PCMTreeMatchLabels(PCMTree(ape::rtree(20)), c("t1", "45"), stopIfNotFound = FALSE)
#> [1] 6 NA