Using R and Shiny to build interactive, data-driven web apps for free

William Nicholas
4 min readMay 28, 2019

--

Data can enable local governments to be more responsive to their citizens and anticipate challenges in their communities. However, analysts face a persistent restraint: “do more with less.” Analysts must be able to present complex data to a multitude of stakeholders, oftentimes without resources like Tableau or PowerBI.

At CoProcure, our emerging data team faced a similar problem. We needed an interactive view of our web traffic, but as a startup we wanted to avoid expensive tools and the complexity of deploying them. Using R and Shiny, we were instead developed an interactive, data-driven web application for free.

The Use Case: Internal Dashboarding

CoProcure is built to serve the nearly 90,000 local governments across the United States. Given the scale of our market, web traffic patterns significantly impact the development decisions we make. To effectively understand that traffic, we needed a fast, flexible web application that users across the organization could access. We chose to build this using R, the leading open-source language for statistical computing, and Shiny, the leading R package for building web applications.

Why R and Shiny?

When selecting a tool for this project, we first considered the usual suspect: JavaScript. While Javascript would have enabled us to create a dashboard within a traditional web development framework, R provided us with several distinct advantages over JavaScript:

Shiny makes the app highly flexible

By developing this tool as a standalone app with Shiny, we can deploy it differently for each audience. Our non-technical staff can quickly review it from a direct link, and it can be simultaneously embedded as part of a larger analytics dashboard for the web team. Given the app’s simplicity, it can also be accessed locally and modified to meet the needs of a particular user.

R is designed for calculations

Processing the data in R is faster and easier than in JavaScript. R provides a simpler syntax and is designed for statistical calculation, giving our team the ability to manipulate large volumes of user data with ease.

R and Shiny reduce organizational overhead

Shiny applications are small enough to be built and deployed by a single analyst. Because they are independently deployed, they can be modified without downstream impact to dashboard pages. And since the visual elements are embedded as part of the app, rather than defined in the destination, the dashboard can be deployed in an HTML page with a single line of code.

How can Shiny Apps with R work for government?

As the audiences for government data grow, governments must match the expectations set by the private sector for data analysis. Being able to deploy timely, interactive snapshots is now a necessity, driven by the popularity of tools like Tableau. R and Shiny give you the tools you need, but without the hassle or the price tag.

This toolset is fast, flexible, and free. It comes with a much lower organizational overhead than large analytics suites like Tableau, and is in widespread use across governments in the United States. It can be easily embedded in a variety of websites, and the independence of each app means that you can configure options that work for each data source. Open data projects can be shared with the world, while secure records are easily kept internally.

Shiny Apps with R can help you ensure compliance and beat Excel.

Using R means each calculation can be reviewed for accuracy. When using Excel, it’s impossible to tell what’s been done to the workbook. Coupled with Shiny’s embedded documentation and logging capabilities, this tool set automates away the error common to Excel processes and ensures your calculations are the same each time.

While data analysis has long been the domain of expensive tools, R and Shiny provide governments the ability to more rapidly find the answers hidden in their data.

About the author: William Nicholas is a technical intern at CoProcure and a graduate student at Indiana University’s O’Neill School of Public and Environmental Affairs, where his focus is data science for public administration. Outside of CoProcure, he has worked in data analysis for political media spending, bail reform, and in the private sector.

CoProcure is an early-stage, venture-backed startup on a mission to reduce the $300B / year wasted in local public purchasing inefficiencies. Our marketplace of competitively-bid contracts can be reused by government buyers, saving time and money for buyers and reducing the cost of selling to governments for suppliers. Want to learn more? Say hi: hello@coprocure.us

--

--