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

Shiny Overview and tutorial

The first step is to install the shiny package

You can run an example shiny app by typing the following in the R console

There is a great starterr set of 7 Shiny tutorials written by RStudio that include examples and code snippets related to visualizing the COVID-19 reporting data. I highly recommend going through these.

Structure of an app.R file

Then let’s examing the example new file (which is also the same as 01_hello. Go to File > New File > Shiny Web App

Click on the Run button and the App will be built

app.R has three components:

a user interface object

a server function

a call to the shinyApp function

It you open a new Shiny file you can see these three components

The user interface (ui) object controls the layout and appearance of your app. The server function contains the instructions that your computer needs to build your app. Finally the shinyApp function creates Shiny app objects from an explicit UI/server pair.

Notice the call to load the libaries (in this case shiny) comes before the code for the shiny app. Other code that feeds into your app (e.g. loading and manipulating data) also comes before the shiny app.

Shiny examples using the COVID-19 Reporting data

In the class GitHub repository there are two examples of shiny apps using the COV-19 Reporting data in the Lab12_HuGen_ShinyApps directory. I have also putting the apps on shiny.io Example Map and Example Graph. * This may take a while to load depending on your computer and internet connection.

In lab today we will code behind some important steps in developing Shiny apps from the COVID-19 reporting data.

The JHU GitHub repository updates

JHU GitHub repository now includes time series data for US states and counties. Here is some starter code for making graphs from this data set. It should be possible to use this data for making Shiny Apps

Graph with states

Graph with Massachusetts counties

Exercises

There are no new exercises, only a challenge to be more creative with your Shiny Apps building off these examples and the new data set.