EDIT: A new version of D3partitionR is now available (0.5), you can find the changelog and updated overview here.
My new package D3partitionR (V0.1) has just been released on CRAN: Here
The git project can be found here
What does it do ?
D3partitionR is an R package to plot several types of interactive plots (using d3js):
- Sunburst
- Partition Layout Chart
- Treemap
- Circle Treemap
All these charts are used to plot hierarchical or sequential data:
- Sequential: Step A -> step B -> step C -> … and so on with several sequences
- Hierarchical: Set C is in Set B which is in set A
As you can see, both these data can be represented using lists:
- [Step A, Step B, Step C]
- [Set A, Set B, Set C]
Thus, the same package and the same functions are to be used to plot these data.
How does it work ?
The package has been thought to be easy to use. It’s only going to take you one single function to create these visualisations !
Input data
The input data are going to be a list of two list:
- The list of the different (and unique) paths
- The value of these paths (i.e. the size of the sets, the number of people using this path and so on …)
EX:
path_in=list(list("A","B","C","D"),list("A","B","F","G"),list("A","D"),list("A","B","END")) value_in=c(15,29,21,34) D3partitionR(data=list(path=path_in,value=value_in))
Will build:
Types of visualisation:
The package gets you access to several type of visualisations, and has a type argument:
D3partitionR(data=list(path=path_in,value=value_in),type="sunburst") D3partitionR(data=list(path=path_in,value=value_in),type="treeMap") D3partitionR(data=list(path=path_in,value=value_in),type="partitionChart")
The different options will respectively gets you a sunburst, a treemap and a partitionChart.
Title and legend:
You can easily add a title through:
D3partitionR( data=list(path=path_in,value=value_in), type="treemap",title=list(text="My title") )
Adding a legend is also easy, you have to specify some colors for some of your steps/sets and to chose the type of legend you want (sequential or categorical).
D3partitionR( data=list(path=path_in,value=value_in),title=list(text="My title"), legend=list(type="sequential",color=list(B="#e8ae46",D="#bf3a8e")) )
What’s next ?
- More options for title, labels and legend
- Adding new type of “partition” charts
- Adding the possibility to use the charts as an input
- Fixing bugs (there will be some !)
- And any other suggestions is more than welcomed !
Your package looks great, but having some trouble getting it to work. The example on this page throws an error – “Error in sum(list_rec_value) : invalid ‘type’ (list) of argument”.
Hi Terry,
The part of the code :
value_in=list(15,29,21,34)
was wrong, replacing it by:
value_in=c(15,29,21,34)
will solve the problem.
The article has been corrected, thanks for your feedback.
Antoine
Yes, That worked. That code fragment would be good to add to the CRAN document.
Hello,
This is a great package, thank you for your work. I like the bubbles visual a lot, but I have one concern: the size of the bubbles is not related to the cumulated values of the leaves (it seems to be determined by the number of subtrees). This can be very misleading as the biggest bubble is not the biggest subtree.
By any chance, would there be a parameter that would enable to fix this?
Philippe
Hello Philippe,
Yes, you’re right there is an issue here, this is not the expected behavior. I will take a look at it an tell you if it is getting ok.
Thanks for noticing the bug,
Antoine
[…] d3partitionR is specialized in plotting hierarchical data using treemaps, circle treemaps, and collapsible trees. This is basically a D3.js wrapper for R and has several options: […]