Learn R Programming

collapsibleTree (version 0.1.5)

collapsibleTree.Node: Create Interactive Collapsible Tree Diagrams from a data.tree

Description

Interactive Reingold-Tilford tree diagram created using D3.js, where every node can be expanded and collapsed by clicking on it.

Usage

# S3 method for Node
collapsibleTree(df, hierarchy_attribute = "level",
  root = df$name, inputId = NULL, width = NULL, height = NULL,
  attribute = "leafCount", aggFun = sum, fill = "lightsteelblue",
  fillByLevel = TRUE, linkLength = NULL, fontSize = 10, tooltip = FALSE,
  ...)

Arguments

df

a data tree from which to a collapsible tree diagram

hierarchy_attribute

name of the data.tree attribute that contains hierarchy information of the tree network. Applicable only for data.tree input.

root

label for the root node

inputId

the input slot that will be used to access the selected node (for Shiny). Will return a named list of the most recently clicked node, along with all of its parents.

width

width in pixels (optional, defaults to automatic sizing)

height

height in pixels (optional, defaults to automatic sizing)

attribute

numeric column not listed in hierarchy that will be used for tooltips, if applicable. Defaults to 'leafCount', which is the cumulative count of a node's children

aggFun

aggregation function applied to the attribute column to determine values of parent nodes. Defaults to `sum`, but `mean` also makes sense.

fill

either a single color or a vector of colors the same length as the number of nodes. By default, vector should be ordered by level, such that the root color is described first, then all the children's colors, and then all the grandchildren's colors.

fillByLevel

which order to assign fill values to nodes. TRUE: Filling by level; will assign fill values to nodes vertically. FALSE: Filling by order; will assign fill values to nodes horizontally.

linkLength

length of the horizontal links that connect nodes in pixels. (optional, defaults to automatic sizing)

fontSize

font size of the label text in pixels

tooltip

tooltip shows the node's label and attribute value.

...

unused; included to match with the generic function

See Also

Other collapsibleTree functions: collapsibleTree.data.frame, collapsibleTree