Learn R Programming

treeplyr (version 0.1.10)

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", as.is = FALSE)

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).

as.is

Whether convert to factors. When FALSE (default), convert character vectors to factors.

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