- RStudio Cloud Notebook
- Getting Started
- Local Deployment
- Remote Deployment
- Making Code Changes
- Cleanup
I chose Plotly for this workshop because it is
- very nicely styled
- has excellent interactivity
- deploys well to the cloud
However, it's also
- extremely touchy & hard to debug
- and that goes double for Plotly R
- 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.
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.
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
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
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
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
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
Remove the local Docker image.
docker image rm workshop
Remove the Heroku app.
heroku apps:destroy viz-workshop-<unique>