tree_match: Match Children in Tree Grob

Description Usage Arguments Details Value Author(s)


Match elements within a tree grob (generated by treeGrob), using the name or class of the child component.


tree_match(tree_grob, class = NULL, name = NULL, warn_no_match = TRUE)



A grob created by treeGrob


The class of the object to match. Currently this can be any class attribute (for cases with multiple inheritance) but this might change soon to be only the primary class. Also it only makes sense to match things with a tree_ prefix so that requirement may also drop soon.


The name of the object to match. Some functions set the name automatically for you (e.g., tree_tip_labels, but others default to a grid provided name, which is varies from use to use unless one is provided manually.


Give a warning if no match is found.


This matches elements that were added to the tree by the + operator; such as tree_grob + tree_node_labels(). A few rules are useful here (and may change).

All classes provided by forest are prefixed with tree_, so elements provided as class will almost always need this adding. I might change things to automatically add this in the future though, as the prefix might change.

tree_tip_labels and tree_node_labels both produce objects with class tree_labels. tree_tip_labels will always have the name of tips and tree_node_labels will always have the name of nodes, so they can be addressed with tree_match(., class="tree_labels", name="tips"), for example.

There can be only one set of branches and this always has the name "branches".

When both specified, class and name must both be satisified.


A list of gPath objects that can be used to reference children relative to tree_grob


Rich FitzJohn

richfitz/forest documentation built on May 27, 2019, 8:17 a.m.