Skip to content

AdeelK93/collapsibleTree

Repository files navigation

Overview

collapsibleTree is an R htmlwidget that allows you to create interactive collapsible Reingold–Tilford tree diagram using D3.js. Turn your data frame into a hierarchical visualization without worrying about nested lists or JSON objects!

If you're using Shiny, you can bind the most recently clicked node to a Shiny input, allowing for easier interaction with complex nested objects. The input will return a named list containing the most recently selected node, as well as all of its parents. See the Shiny example for more info.

Installation

devtools::install_github("AdeelK93/collapsibleTree")

Usage

When working with data in R, it makes sense (at least to me) to represent everything as a data frame. I'm a big fan of tidy data, but this structure does not lend itself to easily designing hierarchical networks.

collapsibleTree uses data.tree to handle all of that, freeing you from a lot of recursive list construction.

Click here to see an interactive version of the chart below.

library(collapsibleTree)

collapsibleTree(warpbreaks, c("wool", "tension", "breaks"))

Collapsible Tree

An interactive Shiny demo is also included. For example, you could use the collapsibleTree htmlwidget to select a portion of a larger categorical dataset, with your filter being as deep or shallow as you'd prefer.

shiny::runApp(paste0(system.file(package="collapsibleTree"),"/examples/02shiny"))

Test Results

library(collapsibleTree)
date()
#> [1] "Mon Mar 13 00:38:49 2017"

testthat::test_dir("tests/testthat")
#> Basic functionality: 
#> Error handling: 
#> 
#> DONE ======================================================================