Description Usage Arguments Examples
Loops over nodes in the tree, applying a function using each node as an argument. Optionally, either the leaves or internal nodes can be dropped from the iteration.
1 | tree.foreach(phylo, fn, leaves = TRUE, nodes = TRUE)
|
phylo |
input phylo object |
fn |
the function to call. For each node, fn will be called with arguments [phylo, node] where node is the node's index within the phylo object. |
1 2 3 4 5 6 7 | set.seed(1)
tree <- rcoal(3)
str <- ''
tree.foreach(tree, function(x, i) {
str <<- paste(str, ' ', tree.get.label(x, i), '=', tree.depth.to.root(x, i), sep='')
})
print(str)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.