I recognize, and fully understand, that this data maybe emotionally difficult to work. My intention is to make these lab relevant, allowing you to gather your own insights directly from new visualizations of the data. Please let me know if you would rather not work with the data.

Learning Objectives

RShiny Overview and tutorial

For this lab session we will use an Introduction to Shiny developed by staff at the National Center for Ecological Analysis and Synthesis (NCEAS) for a workshop on Reproducible Research

Notes

  • Install the shiny package before starting the tutorial.
  • Shiny apps are not created in RMarkdown. They are a different file type, but more similar to R scripts.
  • A new app.R file can be created selecting File > New File > Shiny Web App
  • Add data import and wrangling related code to the beginning of the file, just after you load the libraries.
  • You will need to load the tidyverse library, so be sure to add to the beginning of the code.
  • Be careful when you copy and paste to not add or remove brackets.
  • Once you publish you Shiny App (e.g. to shinyapps.io) you can create a link in your RMarkdown file (e.g. index.Rmd) to the shinyapps.io URL.

18.4.1

replace

bg_chem <- read.csv(data_url, stringsAsFactors = FALSE)

with

bg_chem <- read.csv(url(data_url, method=“libcurl”), stringsAsFactors = FALSE)

18.4.2

After replacing server code block to graph the bgchem data

  • Change plotOutput(“distPlot”) to plotOutput(“depthPlot”)

18.6 +

  • The full code for this section is at the bottom of the page. However, I do recommend replacing each section as you go and only looking to the full code when you are stuck.

Exercises

  1. Make a Shiny App with a graph of the time series data of confirmed cases for with the US and four other countries. Add a slide bar that allows the user to adjust the date.

  2. Make a Shiny App with a graph of the time series data with the US and four other countries. Allow the user to select with type of reporting data (Confirmed, Deaths, Recovered) to be shown in the graph.

  3. Now add to #2 by allowing the user to select which Country_Region

  4. Create a Shiny app using a geographical map.

  5. Create a single Shiny app with the above 4 graphs (and any others you will to add) and publish it on shinyapps.io

  6. On your Github web page add a link to your Shiny apps on shinyapps.io

On Moodle turn in the link to your Github web page