View source: R/node_methods_traversal.R
Traverse | R Documentation |
Traverse takes the root of a tree or a sub-tree, and "walks" the tree in a specific order. It returns a list of
Node
objects, filtered and pruned by filterFun
and pruneFun
.
Traverse(
node,
traversal = c("pre-order", "post-order", "in-order", "level", "ancestor"),
pruneFun = NULL,
filterFun = NULL
)
node |
the root of a tree or a sub-tree that should be traversed |
traversal |
any of 'pre-order' (the default), 'post-order', 'in-order', 'level', 'ancestor', or a custom function (see details) |
pruneFun |
allows providing a prune criteria, i.e. a function taking a |
filterFun |
allows providing a a filter, i.e. a function taking a |
The traversal order is as follows. (Note that these descriptions are not precise and complete. They are meant for quick reference only. See the data.tree vignette for a more detailed description).
Go to first child, then to its first child, etc.
Go to the first branch's leaf, then to its siblings, and work your way back to the root
Go to the first branch's leaf, then to its parent, and only then to the leaf's sibling
Collect root, then level 2, then level 3, etc.
Take a node, then the node's parent, then that node's parent in turn, etc. This ignores the pruneFun
You can also provide a function, whose sole parameter is a Node
object. The
function is expected to return the node's next node, a list of the node's next nodes, or NULL.
a list of Node
s
Node
Get
Set
Do
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.