Learn R Programming

RRphylo (version 3.0.0)

treedataMatch: Cross-reference tree and data

Description

The function matches data names with tree tips. If either there is no data for a tip or it is not present on the tree, the function removes the entry from both.

Usage

treedataMatch(tree,y)

Value

The function returns a list object. If no mismatch between

tree and y is detected, the list only includes the matrix of

y ordered according to the order of tips on the tree ($y). If some tips on the tree are missing from y, they are removed from the phylogeny. Thus, the list also includes the pruned tree ($tree) and the vector of dropped tips ($removed.from.tree). Similarly, if some entries in y are missing from the tree, the list also includes the vector of mismatching entry names ($removed.from.y). In this latter case, the first element of the list ($y) does not include the entries $removed.from.y, so that it perfectly matches the phylogeny.

Arguments

tree

a phylogenetic tree. The tree needs not to be ultrametric and fully dichotomous.

y

named variable. It can be a vector or a multivariate dataset or a 3D array. Alternatively, y can also be a vector of species names.

Author

Silvia Castiglione, Pasquale Raia, Carmela Serio

Examples

Run this code
data(DataCetaceans)
DataCetaceans$treecet->treecet
DataCetaceans$masscet->masscet
DataCetaceans$brainmasscet->brainmasscet

treedataMatch(tree=treecet,y=masscet)
treedataMatch(tree=treecet,y=brainmasscet)
treedataMatch(tree=treecet,y=names(brainmasscet))

Run the code above in your browser using DataLab