tree_match: Match Children in Tree Grob

Description Usage Arguments Details Value Author(s)

Description

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

Usage

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

Arguments

tree_grob

A grob created by treeGrob

class

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.

name

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.

warn_no_match

Give a warning if no match is found.

Details

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.

Value

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

Author(s)

Rich FitzJohn


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