Learn R Programming

ggphylo (version 0.1)

tree.load.data: Loads a data.frame or CSV file into a tree as tags. Requires a 'label' column in the source data, which is used to merge rows in the dataset to labeled nodes in the tree.

Description

Loads a data.frame or CSV file into a tree as tags. Requires a 'label' column in the source data, which is used to merge rows in the dataset to labeled nodes in the tree.

Usage

tree.load.data(phylo, x, ...)

Arguments

phylo
input phylo object
x
input data.frame or string indicating the location of a CSV file.

Value

the phylo object, with tags corresponding to the data from the input dataset.

Examples

Run this code
tree <- tree.read('((a,b)c,d)e;')
x <- data.frame(
  label=c('a', 'b', 'c', 'd', 'e'),
  value=c(1, 2, 3, 4, 5)
)
tree <- tree.load.data(tree, x)
print(as.character(tree)) # as NHX string
print(as.data.frame(tree, minimal.columns=TRUE)) # as data.frame

Run the code above in your browser using DataLab