Dashboards in R Shiny

[This article was first published on r – Appsilon | Enterprise R Shiny Dashboards, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Hero banner with blue hex background and two shiny dashboards with white title text

Data can be transformative when loaded through business intelligence software for strategic decision-making. The insights generated empower businesses to improve their processes, initiatives, and innovations. But can we improve the way business decision-makers access these insights? Enter the world of dashboards in R Shiny and see how RStudio and open source is revolutionizing business intelligence.

Table of Contents


What is a dashboard?

Dashboards are tools that provide up-to-date information, using visuals to communicate the stories behind the data. They guide decision-makers through the relationships of complex, big data. They present visuals in a practical order enabling quicker understanding and appreciation of data to the business.

What is Shiny?

Shiny is an open source R package from the team at RStudio, PBC. RStudio built Shiny to provide an elegant and easy-to-use web framework for developing web applications in R. Shiny enables R users to create incredible apps, interactive maps, and dashboards. And you don’t need advanced web dev skills to build it!

“Shiny combines the computational power of R with the interactivity of the modern web.” – RStudio

Share the story behind your data with quick builds and a variety of hosting and deployment options from RStudio. Deploy to the cloud to services like AWS with RStudio Workbench, use open source options for private projects, or use RStudio Connect to upgrade your Shiny Dashboard for enterprise applications.

Why use dashboards?

  • Timely information – Present critical information in an organized and compact way. Helping decision-makers identify the most valuable answers to decision-related questions. 
  • Access critical insights – Track key performance indicators and trends in sales data, all derived from a variety of data sources. 
  • Improve performance – It’s a window to visualize trends and monitor business metrics.
  • Customization and scale – Fit the needs of individual user roles, departmental requirements, or an entire organization. Improve efficiency in business processes while maintaining brand consistency.
  • Collaboration – Build an interface for collaboration with concurrent users. Enable teams to work together.

Why build dashboards in R Shiny?

Shiny dashboards let you access a complete web application framework within the R environment. Easily turn your work in R, analyses and visualizations, machine learning models, and more into web applications that deliver value to businesses. As a complete application, end-users don’t need an understanding of R to use it. Deliver a complete, easy-to-use, and interactive product that improves the way you do business.

Appsilon builds R Shiny applications for Fortune 500 companies. R and Shiny aren’t the best fit for everyone, but for those looking to solve tough problems with big data, consider adding R Shiny to your tech stack. Explore why companies are switching to R Shiny and why you should too.

Custom Shiny dashboards

Shiny’s web framework enables easy customization of the dashboard using custom HTML, CSS, SCSS, Javascript, and so on. This level of customization lets you create a unique, branded dashboard that’s not possible with other BI software suites. Add colors, logos, fonts, and more that better represent your business.

Cost

Shiny is open source and cost-friendly compared to its counterparts like Power BI and Tableau. You can explore a comprehensive look comparing Power BI to Shiny and Tableau to Shiny on the Appsilon blog.

Don’t want to part with Tableau? Don’t worry – you can now create Tableau Dashboard extensions with R Shiny.

RStudio provides easy-to-use deployment options that range from completely free to low-cost options with additional benefits including security and authentication, scaling, and performance reviews. The ease of deployment as a standalone app to analyze, summarize, and visualize your data story without breaking your budget is hard to beat.

Open Source and accessibility

Shiny as a development platform for dashboards gives you access to a wealth of R packages for data science like the Tidyverse. You can access advanced graphical features for data and model representation.  Embed these visuals on Shiny dashboards and add interactivity and responsiveness. You can achieve this through an interface enabled in R to connect with plotting libraries based on JavaScript. 

Looking at the architecture of the Shiny dashboard, the use of functions, modules, and packages, and rapid-prototyping helps in the management and organization of code. You can create smaller, manageable, and testable components of the dashboards and simple source code controls.

Examples of dashboards in R Shiny

Appsilon has built Shiny dashboards for Fortune 500 companies, NGOs, non-profits, and governments. Over the years they’ve built a showcase of professional and unique Shiny dashboards. RStudio also houses contributions from the Shiny app developer community on their Shiny Gallery. I’ve selected a few examples below:

Check out these 5 Shiny dashboards developed for enterprises and decision-makers.

Shiny dashboard in Health Care

Christian Luz developed the Shiny app below in “the context of a 1339-bed academic tertiary referral hospital to handle data of more than 180,000 admissions.” The app contains 17 unique criteria from which users can filter patient groups. Users can investigate the use of antimicrobials, microbiological diagnostics, and antimicrobial resistance.  Easily stratify and group the results of the investigation “to compare defined patient groups based on individual patient features.”

Dashboard view of RadaR

Shiny dashboard in Government

The Shiny dashboard below shows the New Zealand Trade Intelligence Dashboard. The dashboard shows up-to-date annual information on trade by commodities, services, and trading partners. Wei Zhang used intuitive, interactive graphs and tables to provide powerful functionality. Users can generate their own reports for different commodities and market groups. Wei Zhang developed and designed the dashboard for both PCs and mobile devices.

View of a Health/Life Sciences Dashboard built in R Shiny from the NZ Trade Intelligence

R Shiny dashboard framework

A Shiny application project is made up of a directory containing an R script saved as app.R. The script consists of code describing two components – the user interface object and the server function. Both of which are passed as arguments to the shinyApp function. Resulting in the creation of a Shiny app object either a web app or dashboard.

Note these two components – the UI/server pair can also be split into two separate files namely: ui.R and server.R. The project folder may also contain additional files relating to data, scripts, styles, or other resources required for deployment.

The ui.R, user interface function, contains code that defines how the dashboard looks containing the input and output controls. The server.R, server function containing code, defines how the dashboard works sending back the outputs and interacting with the input values. Shiny uses reactive programming to automatically update outputs when inputs change while the dashboard is running.

Create R Shiny dashboards with Appsilon templates

Appsilon recently release a bundle of Shiny dashboard templates that are free use and customizable. The best and most fun part is – it’s so easy to customize and deploy within minutes, no matter your development environment. 

Appsilon selected the Shiny dashboards based on elements that are customizable and relevant to many projects. The goal is to encourage R Shiny adoption for dashboards and other applications by showcasing the ease of use and customization. The bundle contains four applications that we can select from based on our project.

Hero image with quick looks at the homepages of available templates

Downloading R Shiny Dashboards

First, we download the templates as a zip file from Appsilon Shiny Dashboard Templates. Fill out the form on the page to your local computer. Extract the zip file and save it in your preferred directory.  

For this demo, we’ll use the Destination Overview. Let’s open each of the projects in RStudio. You might get a response like the one below:

Warning message for missing dependencies

It means we don’t have all dependencies used during the development of the templates. To fix this, we need to restore the R environment from the `renv` folder by running the command below from the R console:

Executing this code takes a little while to complete. There might be several packages to download and install to get the environment right. Once we have successfully completed this step, we can run the app by opening either ui.R or server.R and clicking the Run App button.  The resulting dashboard is what you see below:

Destination Overview dashboard in R Shiny view after running on RStudio IDE

Finally, we can deploy the resulting R Shiny Dashboard freely on shinyapps.io. If you don’t have one already, you’ll need to register an account using your preferred email, Google, or GitHub credentials.

You’ll need to install the `rsconnect` package in RStudio and using the console, add your shinyapps.io credentials (name, token, and secret key) for authentication through the console. Use the code below to complete this process:

Dashboards in R Shiny

In summary, dashboards play a key role in business intelligence and analytics. Dashboards are a window to understand and track business metrics through different sources, sizes, and types of data. Dashboards simplify the decision-making process and collaboration among users. Data scientists don’t need to spend time explaining the results and consumers quickly understand the data story. And the availability of Shiny dashboards on the web or mobile platforms gives users more mobility and accessibility.

Shiny can also be neatly integrated into the development pipeline of data professionals using R. Shiny dashboards are versatile, interactive, and easily customized to meet the specific needs of each customer. This is in part due to its web framework that allows the use of web technologies like HTML, CSS, SCSS, JavaScript, and so on. Using Shiny enables the use of modularised codes and functions, rapid prototyping, and easy means of managing the dashboards through smaller components.

Learn how to build, style, scale, and deploy Shiny dashboards with our R Shiny Masterclass.

Article Dashboards in R Shiny comes from Appsilon | Enterprise R Shiny Dashboards.

To leave a comment for the author, please follow the link and comment on their blog: r – Appsilon | Enterprise R Shiny Dashboards.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)