This topic aims to provide you with a foundation for making a shiny app. From this topic, students are anticipated to be able to:
- develop the user interface of a shiny app from scratch,
- develop interactivity using widgets in a shiny app,
- deploy a shiny app to shinyapps.io,
- create interactive Shiny R Markdown documents (embed shiny features within an Rmd file).
And possibly:
- Make an interactive plot with plotly
- Make an interactive data table with the
DT
package
Resources
Video lecture:
Written material:
- “Mastering Shiny” by Hadley Wickham gives a more comprehensive treatment.
- The official shiny site has tutorials, a gallery, and other goodies.
Regarding specific tasks:
- For deploying shiny apps, check out https://www.shinyapps.io/
- For shiny documents (= R Markdown + shiny), see Chapter 19 of Yihui’s R Markdown book.
- For testing your shiny app, check out the shinytest and reactlog packages.
- For further cutting down on code repetition by “functionizing” your shiny app, check out Emily Riederer’s beginner’s guide to Shiny modules for a gentle introduction and Chapter 19 of the “Mastering Shiny” book for a full treatment.
Other dashboard tools besides shiny (but not in R):
- With python: plotly dash. Check out the main website, or this Medium post introducing the tool.
- With javascript: D3, a tremendously powerful tool with a steep learning curve (esp. if you don’t know javascript).
Agenda
We are going to be working off of a slide deck and tutorial written by Dean Attali. This should take two classes.
Test Your Understanding
True or False: A shiny app, as a website, still requires an instance of R running in the background. The stat545.stat.ubc.ca website is static: it doesn’t require an active session to be running in the background.
True or False: Although it’s important to document both a shiny app and an R package, documentation is more important in R packages compared to shiny apps.
True or False: The following code ordinarily has
y
as 15, but usingshiny::reactive()
in a shiny app can havey
equal11
.x <- 10 y <- x + 5 x <- 1
True or False: Since shiny’s UI is html, we can manually write the UI by writing HTML in the
HTML()
function.