This function allows to rename one or more node(s) (levels) in an existing nested hierarchy.

hier_rename(tree, nodes)

Arguments

tree

a (nested) hierarchy created using hier_create() or modified using hier_add(), hier_delete() or hier_rename().

nodes

(character) new names of nodes/levels that should be changed as a named vector: names refer to old, existing names, the values to the new labels

Examples

h <- hier_create(root = "Total",  nodes = LETTERS[1:3])
h <- hier_add(h, root = "A", nodes = c("a1", "a5"))
hier_display(h)
#> Total
#> ├─A
#> │ ├─a1
#> │ └─a5
#> ├─B
#> └─C

h <- hier_rename(h, nodes = c("a1" = "x1", "A" = "X"))
hier_display(h)
#> Total
#> ├─X
#> │ ├─x1
#> │ └─a5
#> ├─B
#> └─C