How to create Waterfall or Pie-Charts and Treemaps in R

As a follow-up on the previous post about “charts and diagrams to impress your audience” I decided to gather some resources on how to accomplish the described graphs in one of the best statistics programs – which to my personal opinion is R – Project for Statistical Computing.

Why is it the best? R is open source, has a great and vibrant community and it runs on every OS. But it has some drawbacks as well: it’s all code input, no plain easy point-and-click user interface and the integration with other tools you usually use – such as Excel for your data or Powerpoint for presenting your findings – are almost not existing.

Waterfall or Bridge Chart in R

I guess there are as many ways to create an waterfall or bridge chart in R, as there are developers out using this software. So I picked two possibilities, which are easy to pursue. The first solution uses the very famous and feature-packed ggplot2 package and can be found on this Learning R blog entry. Since ggplot has no native support of waterfall graphics the author basically recalculates the start and end values of the rectangles of the bar chart. Nevertheless the result is convincing and with some tweaking of the resulting PDF in Adobe Illustrator or similar you are able to create a beautiful graph perfect for describing the origin of a figure. You may also adjust the parameters according to the Aesthetics section to better the design.

The other solution i found is much more straight forward and simply requires the waterfall package from James Howard. The drawback of course is less customization. Find the instructions on this R-Bloggers article.

Multilevel Pie and/or Bullseye Charts in R

Hm, well this get’s a bit tricky and R shows its dark “I-am-for-coders” side. Simple pie charts are very easy to make, follow the advice for instance over at Quick-R. It get’s a bit more vivid at R-Charts’ intro to the pie functionality of ggplot2 and even more sophisticated with the examples demonstrating the capabilities of the ggplot package. Another nice hands-on example for creating a bullseye chart can be found on stackoverflow, where you find other valuable discussions and help for using R if you are willing to dig deeper. Further variations that might be of help are the spie chart or the star plots aka segment diagrams from R-enthusiasts who have a remarkable gallery of various graphs and charts all done in R.

Sadly, for the moment i am not aware of a really manageable tutorial or how-to for creating multi-level pie charts in R.

Sankey Diagrams

Although barely touching on these graphs last time, i ran into a quite lengthy list of tools / tutorials how to generate a Sankey Diagram. Here you also find the free SankeyR function. To achieve the same beauty as the example in my previous post tough, it is nevertheless necessary for you to get the final touches in a graphics program by yourself.

Finally, just let me note that stepping away from average point-and-click software to excellent tools such as R is opening up a new world of possibilities and if you wish to pursue a carrier in statistics or adjacent fields you should definitely dive into it. But if you have to meet a deadline, don’t think of starting to play around with R – you get far to easily distracted ;-) .

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*