R/as.treedata.table.R
as.treedata.table.Rd
This function takes as input a tree of class phylo
or multiPhylo
and a
data.frame
and combines them into a treedata.table. If a multiPhylo
is
provided, all trees must have the same tip.labels. treedata.table
object is
sorted such that the rows in the data.table are matched to the tip.labels
of the phylogeny. Tip.labels on the tree must match a column of tip
names in the input data.frame. The output of this function will be a
treedata.table, which can be manipulated as a data.table.
as.treedata.table(tree, data, name_column = "detect")
tree | A tree of class |
---|---|
data | A dataset in format |
name_column | A character indicating the name of taxa in |
An object of type treedata.table
containing the tree and data.table
data(anolis) anolis2 <- anolis$phy anolis2$tip.label[1] <- "NAA" anolis1 <- anolis$phy anolis1$tip.label[1] <- "NAA" trees <- list(anolis1, anolis2) class(trees) <- "multiPhylo" treesFM <- list(anolis$phy, anolis$phy) class(treesFM) <- "multiPhylo" # A phylo object that fully matches the data td <- as.treedata.table(tree = anolis$phy, data = anolis$dat)#>#>#># A multiphylo object that fully matches the data td <- as.treedata.table(tree = treesFM, data = anolis$dat)#>#>#># A phylo object that partially matches the data td <- as.treedata.table(tree = anolis1, data = anolis$dat)#>#>#>#># A multiphylo object that partially matches the data td <- as.treedata.table(tree = trees, data = anolis$dat)#>#>#>#>