phylobase (version 0.8.2)

phylo4-labels: Labels for phylo4/phylo4d objects

Description

Methods for creating, accessing and updating labels in phylo4/phylo4d objects

Usage

labels(object, ...)
"labels"(object, type = c("all", "tip", "internal"))
labels(x, type, use.names, ...) <- value
"labels"(x, type = c("all", "tip", "internal"), use.names, ...) <- value
hasDuplicatedLabels(x, type)
"hasDuplicatedLabels"(x, type = c("all", "tip", "internal"))
hasNodeLabels(x)
"hasNodeLabels"(x)
nodeLabels(x)
"nodeLabels"(x)
nodeLabels(x, ...) <- value
"nodeLabels"(x, ...) <- value
tipLabels(x)
"tipLabels"(x)
tipLabels(x, ...) <- value
"tipLabels"(x, ...) <- value
hasEdgeLabels(x)
"hasEdgeLabels"(x)
edgeLabels(x)
"edgeLabels"(x)
edgeLabels(x, ...) <- value
"edgeLabels"(x, ...) <- value

Arguments

object
a phylo4 or phylo4d object.
type
which type of labels: all (tips and internal nodes), tip (tips only), internal (internal nodes only).
x
a phylo4 or phylo4d object.
use.names
should the names of the vector used to create/update labels be used to match the labels? See Details for more information.
value
a vector of class character, see Details for more information.
...
additional optional arguments (not in use)

Value

labels in ascending order.

Methods

labels
signature(object = "phylo4"): tip and/or internal node labels, ordered by node ID
hasDuplicatedLabels
signature(object = "phylo4"): are any labels duplicated?
tipLabels
signature(object = "phylo4"): tip labels, ordered by node ID
hasNodeLabels
signature(object = "phylo4"): whether tree has (internal) node labels
nodeLabels
signature(object = "phylo4"): internal node labels, ordered by node ID
hasEdgeLabels
signature(object = "phylo4"): whether tree has (internal) edge labels
edgeLabels
signature(object = "phylo4"): internal edge labels, ordered according to the edge matrix

Details

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.

Examples

Run this code

data(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)

Run the code above in your browser using DataCamp Workspace