tree.foreach: Loops over nodes in the tree, applying a function using each...

Description Usage Arguments Examples

Description

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.

Usage

1
  tree.foreach(phylo, fn, leaves = TRUE, nodes = TRUE)

Arguments

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.

Examples

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)

gjuggler/ggphylo documentation built on May 17, 2019, 6:05 a.m.