How to Develop an R Shiny Dashboard In 10 Minutes or Less
Developing an R Shiny dashboard from scratch can be a time-consuming process. Luckily for you, you don’t need to start from scratch. In 2021 we released four R Shiny dashboard templates that are open to the public. The best part is – you can use and modify them free of charge!
Today we’ll show you how to get started with them. We’ll download the templates from our website, run and customize one of them, and finally, deploy it using shinyapps.io. And we’ll do it all in under 10 minutes.
Need to integrate a database in your R Shiny apps? Check out our detailed guide for Postgres.
Table of contents:
- R Shiny Dashboard Templates from Appsilon
- How to Run An R Shiny Dashboard
- Customize Appsilon’s R Shiny Dashboards
- How to Deploy An R Shiny Dashboard
R Shiny Dashboard Templates from Appsilon
At Appsilon, we’re constantly looking for ways to make life easier for data scientists, individual Shiny developers, and small teams who may not be able to engage Appsilon in a full project. We’ve released a number of open-source R packages to help the R community build better R Shiny dashboards.
In September 2021, we decided to take it a step further by releasing a set of four templates you can use and modify per your liking – completely free of charge.
The Appsilon Shiny Dashboard Template bundle contains 4 applications. Each Shiny dashboard template is a free, open-source dashboard that users can download, install, and customize within minutes. We aim to help the R community quickly launch new projects or augment existing ones.
The Shiny dashboard templates chosen for the bundle contain elements that are easily transferable to a variety of projects and cover three key features for app development:
- Interactivity – e.g., Enterprise Dashboard & Destination Overview
- UI/UX Design – e.g., Fluent UI App
- Simplicity – e.g., Destination Overview & Destination Overview Basic
To get started, simply fill out the form on our templates page and download a zip file:
We’ll see you in the next section where we’ll show you how to restore the R environment and run one dashboard.
How to Run An R Shiny Dashboard
We’ll work on the Enterprise dashboard throughout the article. Here’s what it looks like on our demo page:
We assume you’ve downloaded our Shiny templates Zip file and that you have it extracted somewhere locally. The next step is to open the shiny-enterprise-dashboard folder as an RStudio Project:
It’s likely you don’t have all dependencies we used during development, so that’s where the next step comes in. You’ll have to restore the R environment from the
renv folder. It’s easier than it sounds actually, as it boils down to running a single command from the R console:
It might take a while, as there are plenty of packages that have to be downloaded and installed. Once done, you can open either
server.R and hit the Run App button – here’s what you will see:
You’re all set to begin customizing the dashboard. Let’s do that in the following section.
Customize Appsilon’s R Shiny Dashboards
We’ll do a couple of modifications in this section, both on the UI and Server logic. We’ll start by working on the styles – modifying the text and colors shown on the dashboard.
Change the styles
To change the overall blue theme on our R Shiny dashboard, we’ll first have to open the
variables.scss configuration file. You can find it under the styles/config/ folder. Change the following variables to have the following values:
These hex codes represent different shades of green, so the variable names aren’t representative. You can change them if you wish, but we won’t for the purpose of this article.
Next, navigate to
modules/breakdown_chart.R and change line 61 to match the following:
We’ll have to do something similar in
modules/time_chart.R, but this time on lines 82 and 83. Make sure they have the following values for colors:
constants.R and change the following:
And these are all the changes you need to make to make the dashboard green. We’ve also modified some text, so let’s verify everything works. Your dashboard should look like this once you run it:
It’s definitely a good start, but let’s also see how to change the server logic.
Change the charts
We’ll change the bottom Breakdown chart slightly in this section. We’ll go from a horizontal bar chart to a vertical one. To do so, open up
modules/breakdown_chart.R and modify the code starting at line 68. We don’t need
coord_flip() anymore and we also have to modify the text position.
Here’s the entire code snippet:
Let’s run the dashboard again and see what we’re dealing with:
It’s not a groundbreaking change, but lets you see how easy it is to tweak Appsilon templates, both from the UI and Server perspective.
The Breakdown chart was made with
ggplot2. If you’re not familiar with ggplot2, read our detailed guides:
There’s only one thing left to do. Deployment!
How to Deploy R Shiny Dashboards
We’ll now show you how to deploy your R Shiny Dashboard on shinyapps.io. You’ll have to register for a free account first. You can use your Google or GitHub credentials to shorten the process.
Once done, you’ll have to install the
rsconnect package from the R console and authenticate through it. You can find authentication details (name, token, and secret key) on the shinyapps dashboard page:
Almost there! From the R console, import the
rsconnect package and call the
deployApp() function as shown below:
You should see the following output after a couple of minutes:
The deployed dashboard will open automatically. Here’s what ours looks like:
And that’s how you go from a template to a deployed dashboard in 10 minutes. Let’s wrap things up next.
You don’t have to be an expert R Shiny developer to make usable dashboards. Our templates can help if you don’t have the time to learn all the little tricks and fine details that make Appsilon a global leader in developing R Shiny dashboards. Plus, they show you exactly how you should structure your code when developing commercial applications.
We’ve only scratched the surface today, so here are a couple of homework assignments you can work on:
- Change the Sales Revenue bar chart type from stacked to grouped.
- Add a custom logo instead of Appsilon’s.
- Use a different library to configure the map (Sales Revenue by Country) – possibly Leaflet?
Feel free to share results with us on Twitter – @appsilon. We’d love to see what you came up with.
Interested in learning R Shiny further? Here’s how to start a career as an R Shiny developer.
If you need a PoC fast or an improvement on an existing concept, reach out to us. Appsilon is a global leader in R/Shiny development. And the Appsilon team plays an active role within the R/Shiny community, developing and maintaining open source packages and Shiny templates. From design to infrastructure, our Shiny tools can be used to build efficient, beautiful Shiny applications that scale. We’ve got the skillset to solve the most challenging of problems and we’re an RStudio Full Service Certified Partner.