Learn R Programming

treeplyr (version 0.1.7)

make.treedata: Function for making an object of class treedata

Description

This function generates an object of class treedata that ensures that the ordering of tip labels and data remain intact. The object can be manipulated using dplyr functions.

Usage

make.treedata(tree, data, name_column = "detect")

Arguments

tree

An object of class 'phylo'

data

A data frame or matrix

name_column

An optional argument that specifies the column of data that contains the names to be matched to the tree. By default, it is set to "detect" which finds the column with the most matches to the tree (including the rownames).

Value

An object of class "treedata". The tree is pruned of tips not represented in the data, and the data is filtered for taxa not in the tree. The data is returned as a data frame tble that is compatible with dplyr functions.

Examples

Run this code
# NOT RUN {
data(anolis)
td <- make.treedata(anolis$phy, anolis$dat)
# }

Run the code above in your browser using DataLab