Interactive data with Shiny flexdashboard
2023-10-19
Overview
This lesson is meant to be a cursory look at creating interactive dashboards using RMarkdown + flexdashboard
with Shiny integration. Roughly we will…
- Introduce and discuss interactive sites
- Overview of
flexdashboard
and its layout scheme
- Create a dashboard with static interaction (does not rely on Shiny)
- Create a dashboard with dynamic interaction (does rely on Shiny)
- Discuss options for themes and styles
- Publish the site
A note on Shiny: The focus of this lesson is integrating elements of Shiny through the RMarkdown interface via flexdashboard
, which is different than learning classic Shiny via the shiny
package. More standard tutorials for learning Shiny, such as Posit’s introduction, can show you how to build an app without flexdashboard
. Personally, I think learning Shiny via flexdashboard
is a good gateway, as it introduces some (but not all) of the concepts needed for more advanced app-building.
Set up
Package installation
It will be useful to make sure the following packages are installed, especially if your computer is sometimes buggy downloading packages.
Make a shinyapps.io account
If you want to actually publish the page we make in this lesson, you will need to create a Shiny account and link it to your RStudio. To do this, please complete the following steps:
- create a Shiny account
- Follow the instructions for publishing in RStudio by navigating to Tools > Global Options > Publishing.
Once on this pane, you’ll click Connect > shinyapps.io and follow the instructions to link your account.
Review conditionals
This is not essential, but one of the trickiest parts of making documents interactive is setting the right conditionals for re-shaping your data. I would recommend revisiting the logic behind conditional statements in R, which include if...else
, ifelse()
, and case_when()
functions. This tutorial will use the if...else
syntax, so maybe worth brushing up on.