hier_rename: Rename nodes in an existing hierarchy

View source: R/hier_rename.R

hier_renameR Documentation

Rename nodes in an existing hierarchy

Description

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

Usage

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)

h <- hier_rename(h, nodes = c("a1" = "x1", "A" = "X"))
hier_display(h)

sdcHierarchies documentation built on May 29, 2024, 8:01 a.m.