Combining the Power of DeployR, rCharts, and AngularJS

Revolution R Enterprise DeployR is a server framework that exposes the R platform as a service allowing the integration of R statistics, analytics and visualizations inside Web, desktop and mobile applications. DeployR’s framework allows users to store and serve up R code that can then easily be used and reused in your own interfaces. By separating the R code from the UI code, not only can you leave the analytics to the R developer and the UI designs to the web developers, but you can also make it easier to unit test and debug the R code. Additionally, this separation of R and UI allows you to make the best use of the best software for each. You can take advantage of choice UI frameworks, such as AngularJS, to develop and solve front-end design issues and DeployR for managing and executing high powered R analytics.

We’ve been getting lots of questions about the rCharts package and whether rCharts output can be integrated into DeployR. The answer is yes — it is a wonderful way to create a chart in R that you can then augment with interactivity using HTML and JavaScript. Below is an example of code designed to be executed only once on the DeployR server and then interacted with numerous times on the client-side without any additional load on the server.

A few weeks ago, Joseph Rickert introduced a method for retrieving package information from CRAN. He created a count of the number of Depends per package, and then plotted a histogram of this count. This same data is used in the example below to demonstrate how to combine DeployR, rCharts, and AngularJS to display some histograms. The code itself will execute only once and all additional interactions occur on the client.

This chart was built with:

An R script (Histograms.R) stored on the DeployR server and publicly accessible. This script creates a chart using the rCharts package.

An HTML page (index.html) that displays the chart and its interactive controls.

A JavaScript file (script.js), using the AngularJS framework, that runs the script once on the DeployR server, and then updates the chart on the client-side whenever a user changes one of the controls.

You can download the R, HTML, and JavaScript files here. NOTE: Due to the libraries used in the JavaScript code, this chart is best viewed in the latest version of Chrome, FireFox, Safari, or IE 9+.