Skip to content
R htmlwidget package for creating a sankey tree plot
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
build
examples
inst/htmlwidgets
man
tests
theSrc
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE
Makefile
NAMESPACE
NEWS.md
README.Rmd
README.md
gulpfile.js
package.json
rhtmlSankeyTree.Rproj

README.md

rhtmlSankeyTree

Sankey Diagrams as Collapsible Trees

Combining Sankey diagrams with collapsible trees and adding some new interactivity might help us analyze, instruct, and decide.

Installation in R

Important

This package uses a customised htmlwidget package that allows local state saving. The official htmlwidget package will not work. Download the customised package by running install_github('Displayr/htmlwidgets')

Installation

  1. library(devtools)
  2. install_github('Displayr/htmlwidgets')
  3. install_github('Displayr/rhtmlSankeyTree', auth_token='????????????????????')

An example to verify installation:

    library(rpart)
    library(partykit)
    library(pipeR)
    library(rhtmlSankeyTree)

    #set up a little rpart as an example
    rp <- rpart(
      hp ~ cyl + disp + mpg + drat + wt + qsec + vs + am + gear + carb,
      method = "anova",
      data = mtcars,
      control = rpart.control(minsplit = 4)
    )

    # convert rpart to a hierarchy using convert_rpart in converters.R
    rhtmlSankeyTree:::convert_rpart(rp)

    #see what it looks like
    SankeyTree(rp)

    SankeyTree(rp, maxLabelLength = 25, nodeHeight = 100)

    # do with kyphosis example
    SankeyTree(
      rpart(Kyphosis ~ Age + Number + Start, data = kyphosis),
      maxLabelLength = 25,
      nodeHeight = 100
    )

Local Installation to Develop/Contribute

Prerequisites - For help installing prerequisites see the Prequisite Installation Help section below

  1. nodejs >= 6.0
  2. python 2.7 - one of the nodejs libraries needs python during the installation process

Installing the rhtmlSankeyTree code

  1. On windows open git shell (or install it first). On OSX open terminal
    1. Tim note : Type enter when prompted for a passphrase when opening git shell
  2. Change directory to the place where you put git projects
    1. Tim note : Do not use a Dropbox synced directory. There will be 1000's of files created by npm install and your computer will catch fire
  3. type git clone git@github.com:Displayr/rhtmlSankeyTree.git ENTER
  4. type cd rhtmlSankeyTree ENTER
  5. type npm install ENTER
    1. npm install is noisy and will print several warnings about UNMET and DEPRECATED. Ignore these and only make note of errors. If it fails, try running it again.
  6. type gulp serve ENTER
    1. If gulp serve does not work try ./node_modules/.bin/gulp serve. To correct this and to make your nodejs life easier you should add ./node_modules/.bin to your PATH. Consult the Internet for instructions on how to do so on your OS of choice.
    2. Auto-reload will be enabled with gulp serve, meaning that any changes saved to the specific files in folders scripts, internal_www and styles inside the theSrc folder will trigger an automatic browser reload.
  7. If you do not wish to have auto-reload enabled, run gulp serve_s instead.

If this worked, then the gulp serve command opened your browser and you are looking at http://localhost:9000. You should see a page listing a bunch of links to examples. These examples are defined in the internal www content directory.

Prerequisite Installation Help

Install nodejs on OSX

  1. Install brew by following instructions here : http://brew.sh/
  2. Install nvm (node version manager) by running brew install nvm
  3. Install node by running nvm install 6.1.0 on the terminal

Install nodejs on Windows

  1. Setup nodist. https://github.com/marcelklehr/nodist and find the link to the official installer.
  2. Open the command prompt. Type: nodist v6.1.0
  3. Type node -v and verify the version is correct

Python on OSX - it should come installed. If not

  1. Install brew (if not done already) by following instructions here : http://brew.sh/
  2. Install python by running brew install python on the terminal - make sure you get 2.7

Python on Windows

  1. Download version 2.7 from https://www.python.org/downloads/

Developing and Contributing

  1. The last thing you do before committing is run gulp build to ensure all the autogenerated files are up to date.
  2. DO NOT edit things in browser, inst and man folders as they are auto-generated and will be recompiled from theSrc folder when gulp build or gulp serve is called. It is safe to edit files in R, theSrc, examples and data.

License

See the LICENSE file GPL-3 + COPYRIGHT HOLDER: Displayr

You can’t perform that action at this time.