Presenting interactive data visualisations with Shiny Apps

By Iris Hoekstra-Roscam Abbing

Lately, Auke and I have been discovering the awesomeness of the R language and its IDE RStudio, the open source solution for data analysis and visualization. The following post assumes some basic knowledge of R.

So, you’ve done some nifty things in R. Now, of course, you want to show them to the world! What is the best way to present your analysis results on the internet? It depends. Many times, a graph exported to jpeg or png format is a perfect solution. If you have several graphs and want to show off your calculations as well, in other words, if you have longer story to tell, an R markdown document can be the way to go. RStudio can generate nice, clean HTML based on R markdown.

But what if you want to add… interactivity? Something like a slider – or other UI element – the user can play with, after which the results (a graph, or some other form of output) get updated? That would totally impress your boss, right?

Once you’ve got the hang of R programming, it is not hard to learn to make Shiny apps. Shiny apps are presentable looking, more or less responsive web apps which are generated based on R code, if you have the Shiny package installed that is. Web programming experience is not required (although, if you have it, you can add your own css or javascript to your app without much hassle).

The only setback is that hosting a Shiny app that may be viewed by many people is going to be challenging, or costly, or both. You can very easily upload a Shiny app from RStudio to shinyapps.io. However, their free plan only allows the app to run for 25 hours a month. You can change this by getting a paid plan. Paid plans start at 39 US$ a month, which may a bit hefty if you’re just a guy with an interesting hobby. Setting up your own Shiny server may be worth while but of course setting up servers is not everybody’s cup of tea. The server comes in a free and a paid version and the free version has its limitations of course. Even the paid versions do. All in all, Shiny apps are great if you want to share your work with a limited number of people but are probably less suitable for a high-traffic news site, for example.

Below is an example of a Shiny app. It is a text prediction application which I developed as part of the Coursera Data Science Specialization which, by the way, I very highly recommend (if you have plenty of time on your hands and a very understanding spouse, that is, because this is a course program that will take over you life!) Obviously text prediction has very little to do with electric vehicles and charging infrastructure but Shiny apps could be useful in any field of research and I just wanted to see how hard it would be to share one on a blog.

I just stuck the app in an iframe, to see if it would work. It does. However, I am on the free plan, so if this blog suddenly were to get a lot of attention, you will just see a message along the lines of “this user has used up his/her monthly hours”!