Learn R Programming

collapsibleTree (version 0.1.5)

collapsibleTree.data.frame: Create Interactive Collapsible Tree Diagrams from a data.frame

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 data.frame
collapsibleTree(df, hierarchy,
  root = deparse(substitute(df)), inputId = NULL, width = NULL,
  height = NULL, attribute = "leafCount", aggFun = sum,
  fill = "lightsteelblue", fillByLevel = TRUE, linkLength = NULL,
  fontSize = 10, tooltip = FALSE, ...)

Arguments

df

a data frame from which to construct a nested list

hierarchy

a character vector of column names that define the order and hierarchy of the tree network. Applicable only for data.frame 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.Node, collapsibleTree