Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Latest commit

 

History

History
151 lines (97 loc) · 3.77 KB

README.md

File metadata and controls

151 lines (97 loc) · 3.77 KB

Dockerized Covid Dash in R

Table of Contents

RStudio Cloud Notebook

I chose Plotly for this workshop because it is

  1. very nicely styled
  2. has excellent interactivity
  3. deploys well to the cloud

However, it's also

  1. extremely touchy & hard to debug
  2. and that goes double for Plotly R
  3. double it again in Docker

So it's worth being clear that in developing this code, I used RStudio in the early stages.

RStudio Cloud is a free service that is great for trying code out and learning new packages in a controlled environment.

I'm therefore providing one of these scripts running in a public notebook by way of example: https://rstudio.cloud/project/3676724

As you'll see, the syntax is a little different! R has been updated -- and down the line, I'm likely to update this git repo as well to reflect those changes.

Return to Top

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