rCharts | Bypeople


Recently, I had blogged about two R packages, rCharts and rNVD3 that provided R users a lattice like interface to create interactive visualizations using popular javascript libraries.

There was a lot of repeated code between the two packages, which lead me to think that it might be possible to integrates multiple JS libraries into a single package with a common lattice like interface. After heavy refactoring, I finally managed to implement three popular JS libraries in rCharts: Polycharts, NVD3 and MorrisJS.

rCharts uses reference classes, which I believe is one of the best things to happen to R. It allowed me to keep the code base pretty concise, while implementing a fair degree of functionality. The current structure of rCharts should make it easy to integrate any JS visualization library that uses a configuration variable to create charts. This includes Highcharts and Vega, which have R implementations in rHighcharts and rVega.

A huge advantage of wrapping these libraries within the same package is that they can take advantage of the common code. For example, when I implemented MorrisJS, I only had to focus on the data structure required by the library. All the other parts like rendering, integration with shiny and slidify, were derived from the parent class.

All JS libraris in rCharts are compatible with Slidify. In fact, this blog post was created by running Slidify on the source Rmd file! I have provided one example for each of the three libraries to give you a flavor of what is possible, and will be posting more examples shortly.

If you have an interesting JS plotting library that you would like to see added, or have feedback, please post here on github.

Related Deals

Related Posts