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.
treedataMatch(tree,y)
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.
Returns
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.