Making Custom Web-Based Data Visualizations with Free R Packages

By Lillian Pierson

The tools presented here require you to code using the R statistical programming language. Although you may not have much fun coding things up yourself, with these packages and tools, you can create results that are more customized for your needs. You can use Shiny, rCharts, and rMaps to create really neat looking web-based data visualizations.

Getting Shiny by RStudio

No too long ago, you needed to know how to use a statistics-capable programming language like R if you wanted to do any kind of serious data analysis. And if you needed to make interactive web visualizations, you’d have to know how to code in languages like JavaScript or PHP.

Of course, if you wanted to do both simultaneously, then you’d have to know how to code in an additional two or three more programming languages. In other words, web-based data visualization based on statistical analyses was a cumbersome task.

The good news is that things have changed. Due to the work of a few dedicated developers, the walls between analysis and presentation have crumbled. After the 2012 launch of RStudio’s Shiny package, both statistical analysis and web-based data visualization can be carried out in the same framework.

RStudio — already, by far, the most popular integrated development environment (IDE) for R — developed the Shiny package to allow R users to create web apps. Web apps made in Shiny run on a web server and are interactive — with them, you can interact with the data visualization to move sliders, select check boxes, or click the data itself.

Because these apps run on a server, they’re considered live — when you make changes to the underlying data, those changes are automatically reflected in the appearance of the data visualization. Web apps created in Shiny are also reactive — in other words, their output updates instantly in response to a user interaction, without the user having to click a Submit button.

If you want to quickly use a few lines of code to instantly generate a web-based data visualization application, then use R’s Shiny package. What’s more, if you want to customize your web-based data visualization app to be more aesthetically appealing, you can do that by simply editing the HTML, CSS, and JavaScript that underlies the Shiny application.

Because Shiny produces server-side web apps, you need a server host and the know-how to host your web app on a server before you can make useful web apps by using the package.

Shiny runs a public web server called can use that server to host an app for free, or you can pay to host there if your requirements are more resource-intensive. The most basic level of service costs $39 per month and promises you 250 hours of application run time per month.

Charting with rCharts

Although R has always been famous for its beautiful static visualizations, only just recently has it been possible to use R to produce web-based interactive data visualizations.

Things changed dramatically with the advent of rCharts. rCharts is an open-source package for R that takes your data and parameters as input and then quickly converts those to a JavaScript code block output. Code block outputs from rCharts can use one of many popular JavaScript data visualization libraries, including NVD3, Highcharts, Rickshaw, xCharts, Polychart, and Morris.

To see some examples of data visualizations created by using rCharts, check out the rCharts Gallery. This gallery includes simple data graphics such as standard bar charts and scatterplots, as well as more complex data graphics such as chord diagrams and hive plots.

Mapping with rMaps

rMaps is the brother of rCharts. Both of these open-source R packages were crafted by Ramnath Vaidyanathan. Using rMaps, you can create animated or interactive choropleths, heatmaps, or even maps that contain annotated location droplets (such as those found in the JavaScript mapping libraries Leaflet, CrossLet, and Data Maps).

rMaps allows you to create a spatial data visualization that contains interactive sliders that users can move to select the data range they want to see.

If you’re an R user and you’re accustomed to using the simple R Markdown syntax to create web pages, you’ll be happy to know that you can easily embed both rCharts and rMaps in R Markdown.

If you prefer Python to R, Python users aren’t being left out on this trend of creating interactive web-based visualizations within one platform. Python users can use server-side web app tools such as Flask — a less–user-friendly, but more powerful tool than Shiny — and the Bokeh and Mpld3 modules to create client-side JavaScript versions of Python visualizations.

The Plotly tool has a Python application programming interface (API) — as well as ones for R, MATLAB, and Julia — that you can use to create web-based interactive visualizations directly from your Python IDE or command line. (Check out Flask, Bokeh, Mpld3, and Plotly.)