Dockerized Covid Dash in R

Table of Contents

Getting Started

This repo contains 3 builds of a Plotly app in R for quantifying covid-related mortality.

It also contains a Dockerfile for deploying local and remote environments.

Data and Apps

These apps parse a large csv (~50MB) from the CDC: https://data.cdc.gov/NCHS/Weekly-counts-of-death-by-jurisdiction-and-cause-o/u6jv-9ijr/

  • sample.R displays weekly mortality by for one cause, state, and year
  • sample_withloop.R -- by multiple years for one cause and state
  • sample_loop_plus_selector.R -- by multiple years with state, cause, & count type selectors

Requirements

Fork and Clone the Project

Fork the rice-crc/plotly_visualization_workshop repository on GitHub.

Clone the fork locally. Substitute your GitHub username.

git clone https://github.com/<username>/plotly_visualization_workshop
cd plotly_visualization_workshop

Return to Top

Local Deployment

Build the Plotly Docker image.

docker build -t workshop .

Use a container to test the default sample.R script.

docker run --rm -p 8050:8050 workshop

View running apps by opening a browser window and visiting http://0.0.0.0:8050/. Stop and remove containers by hitting ctrl-c on the command line.

Use containers to test the additional R scripts.

docker run --rm -p 8050:8050 workshop sample_withloop.R
docker run --rm -p 8050:8050 workshop sample_loop_plus_selector.R

Return to Top

Remote Deployment

Create a new app in Heroku. Substitute a unique string in the app name.

heroku create --stack container viz-workshop-<unique>

Push the code to the Heroku app and deploy.

git push heroku main

Return to Top

Making Code Changes

After making code changes, test the app locally by following the "Local Deployment" section above.

When ready, commit and push the changes to your GitHub fork.

git add .
git commit -m "<description of changes>"
git push

Deploy the new code to your Heroku app.

git push heroku main

Return to Top

Cleanup

Remove the local Docker image.

docker image rm workshop

Remove the Heroku app.

heroku apps:destroy viz-workshop-<unique>

Return to Top