Skip to contents

Returns the human-readable path for a single leaf identified by its flat index (e.g. "a$b" or "[[2]]"). Only descends into the branch containing the target leaf, making it efficient for error reporting.

Usage

tree_path(tree, i)

Arguments

tree

(RTree)
A tree as returned by build_tree().

i

(integer(1))
The flat index of the leaf.

Value

character(1) ("" for a leaf at the root).

Examples

tree_path(build_tree(list(a = 1, b = list(c = 2))), 2L)
#> [1] "b$c"