Creating Shiny Web Apps With R

There is no doubt we are living in an era driven by data. Important decisions are taken based on systematic observations and those who can manage and analyze data have great potential if placed in the right context. It’s reasonable that “data scientist” has been described as the “sexiest job of the 21st century”.

Of course, the trick is to be able to give meaning to the data and communicate results in an understandable way that can lead to actions or decisions. This can be done in a static manner, by preparing graphs and tables and sharing them with some comments. Some things, though, aren’t easy to represent in one graph, especially with the amount of data we have today. Almost everything around us is collecting data and sometimes we need to interact with it to be able to understand it better.

That’s when dashboards are quite useful; A data scientist can prepare the data and create dynamic, interactive plots that get updated automatically as more data is available and allow the user to interact with it, for example by filtering certain variables or changing the scale or time range to focus on certain parts of the data.

With the rise of open science, the possibility to create dashboards with data from one’s project can also be a great way to give other scientists the chance of exploring further the dataset and maybe find new patterns or even point out some errors that the original author didn’t notice. This could be an indispensable tool for reproducible science, especially in the light of the replication crisis that has become a big issue in the past decade or so.

Nowadays it has become relatively easy to create dashboards, with platforms like Tableau. As for those who have some coding experience, there is Shiny!

Shiny for R allows creating web applications and dashboards without leaving R. It has widgets to support a whole range of elements and it builds a ready-to-publish webpage with both front- and backend. It is very easy to deploy on local network, private server or in the cloud, and with services like shinyapps.io one could get their dashboard or web app online in no time.

Trying to get acquainted with it, I started fiddling to create interfaces for some R functions that I have written. My first shiny app is pupil2blinks, a simple interface to the functions I have discussed in a previous article.

In this app one could either use the sample data or upload their own TSV file (tab-separated values) with the timestamp and pupil columns. Then the app would run two different blink filters and plot them in different tabs, along with the raw data.

This is a very simple example of what can be done with Shiny. If you want to develop your first shiny app I advise you to check the articles and tutorials on their website.

If you would like to add a dashboard to your project or need help with your data processing, feel free to contact me on this form or on social media below.