formatToHierarchicalData: Format data to a hierarchical data, in the format as required...

View source: R/plots-utility-formatToHierarchicalData.R

formatToHierarchicalDataR Documentation

Format data to a hierarchical data, in the format as required by the plotly sunburst and treemap.

Description

Note that new variables are created for each variable of interest (the variables are not overwritten) to avoid issues with cases where the value in the child and parent variables are the same.

Usage

formatToHierarchicalData(data, vars, valueVar)

Arguments

data

Data.frame with data.

vars

Character vector with variables of data containing the groups. If multiple, they should be specified in hierarchical order (from parent to child node).

valueVar

String with numeric variable of data containing the value to display.

Value

Updated data.frame with vars in hierarchical format, with extra attributes (in 'metadat'):

  • 'varID': String with column of output containing ID of specific element.
    This is a combination from the specified vars, or 'Overall' for the grand total.

  • 'varParent': String with column of output containing ID of the parent element

  • 'varLabel': String with column of output containing the label to display.
    This is usually the name of the child element.

Author(s)

Laure Cougnaud


clinDataReview documentation built on March 7, 2023, 5:13 p.m.