phylo4-labels {phylobase} | R Documentation |
Methods for creating, accessing and updating labels in phylo4/phylo4d objects
## S4 method for signature 'phylo4': labels(object, type=c("all", "tip", "internal")) ## S4 method for signature 'phylo4, ANY, ANY, character': labels(x, type=c("all", "tip", "internal"), use.names=FALSE) <- value ## S4 method for signature 'phylo4': tipLabels(x) ## S4 method for signature 'phylo4, character': tipLabels(x) <- value ## S4 method for signature 'phylo4': hasNodeLabels(x) ## S4 method for signature 'phylo4': nodeLabels(x) ## S4 method for signature 'phylo4, character': nodeLabels(x) <- value ## S4 method for signature 'phylo4': hasEdgeLabels(x) ## S4 method for signature 'phylo4': edgeLabels(x) ## S4 method for signature 'phylo4, character': edgeLabels(x) <- value
x |
a phylo4 or phylo4d object. |
object |
a phylo4 or phylo4d object. |
type |
which type of labels: all (tips and internal nodes),
tip (tips only), internal (internal nodes only). |
value |
a vector of class character , see Details for more
information. |
use.names |
should the names of the vector used to create/update labels be used to match the labels? See Details for more information. |
In phylo4/phylo4d objects, tips must have labels (that's why there is no method for hasTipLabels), internal nodes and edges can have labels.
Labels must be provided as a vector of class character
. The
length of the vector must match the number of elements they label.
The option use.names
allows the user to match a label to a
particular node. In this case, the vector must have names that match
the node numbers.
The function labels
is mostly intended to be used
internally.
signature(object = "phylo4")
: tip and/or
internal node labels, ordered by node IDsignature(object = "phylo4")
: tip labels,
ordered by node IDsignature(object = "phylo4")
: whether
tree has (internal) node labelssignature(object = "phylo4")
: internal
node labels, ordered by node IDsignature(object = "phylo4")
: whether
tree has (internal) edge labelssignature(object = "phylo4")
: internal
edge labels, ordered according to the edge matrixdata(geospiza) ## Return labels from geospiza tipLabels(geospiza) ## Internal node labels in geospiza are empty nodeLabels(geospiza) ## Creating internal node labels ndLbl <- paste("n", 1:nNodes(geospiza), sep="") nodeLabels(geospiza) <- ndLbl nodeLabels(geospiza) ## naming the labels names(ndLbl) <- nodeId(geospiza, "internal") ## shuffling the labels (ndLbl <- sample(ndLbl)) ## by default, the labels are attributed in the order ## they are given: nodeLabels(geospiza) <- ndLbl nodeLabels(geospiza) ## but use.names puts them in the correct order labels(geospiza, "internal", use.names=TRUE) <- ndLbl nodeLabels(geospiza)