as.mulTree | R Documentation |
Combines a data table and a multiple phylogenies. Changes the name of the taxa column into "sp.col" to be read by MCMCglmm
.
as.mulTree(data, tree, taxa, rand.terms, clean.data = FALSE)
data |
A |
tree |
A |
taxa |
The name or the number of the column containing the list of taxa in the |
rand.terms |
A |
clean.data |
A |
If rand.terms
is specified by the user, the first element is forced to be called "animal".
A mulTree
object the data to be passed to the mulTree
function.
Thomas Guillerme
mulTree
##Creates a data.frame
data_table <- data.frame(taxa = LETTERS[1:5], var1 = rnorm(5),
var2 = c(rep("a",2), rep("b",3)))
##Creates a list of tree
tree_list <- rmtree(5,5, tip.label = LETTERS[1:5])
##Creates the "mulTree" object
as.mulTree(data_table, tree_list, taxa = "taxa")
##Creating a mulTree object with multiple specimens
##Creates a data.frame with taxa being labelled as "spec1"
data_table_sp1 <- data.frame(taxa = LETTERS[1:5], var1 = rnorm(5),
var2 = c(rep("a",2), rep("b",3)), specimen = c(rep("spec1", 5)))
##Creates a data.frame with taxa being labelled as "spec2"
data_table_sp2 <- data.frame(taxa = LETTERS[1:5], var1 = rnorm(5),
var2 = c(rep("a",2), rep("b",3)), specimen = c(rep("spec2", 5)))
##Combines both data.frames
data_table <- rbind(data_table_sp1, data_table_sp2)
##Creates a list of tree
tree_list <- rmtree(5,5, tip.label = LETTERS[1:5])
##Creates the "mulTree" object (with a random term formula)
as.mulTree(data_table, tree_list, taxa = "taxa", rand.terms = ~taxa+specimen)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.