Last active
November 4, 2020 19:50
-
-
Save Azlirn/a37c4306b8f011a27885500d73d2f2b9 to your computer and use it in GitHub Desktop.
[IN DEVELOPMENT] An R script that pulls COVID-19 data from a variety of sources and analyzes specific data points to track changes in regional COVID-19 severity for the state of New York.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "New York State Regional COVID-19 Breakdown" | |
output: html_notebook | |
--- | |
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. | |
<hr> | |
```{r} | |
# Load libraries needed for retrieving data from the COVID Act Now API. | |
library(httr) | |
library(jsonlite) | |
library(dplyr) | |
library(ggplot2) | |
``` | |
Retrieve and Process COVID-19 Summary Data for New York State | |
```{r} | |
# COVID Act Now - Data by County (Nationwide Summary) | |
req = GET(url="https://api.covidactnow.org/v2/counties.json?apiKey=4d04a4db2e1945659ec528545143acd1") | |
county_summary <- fromJSON(content(req, as="text"), flatten=TRUE) | |
# Filter for NYS County Level Data | |
nys_summary_county <- filter(county_summary, state=='NY') | |
head(nys_summary_county) | |
``` | |
Alternative method for converting API request to R Object: | |
```county_summary <- as.data.frame(fromJSON(rawToChar(req$content)))``` | |
```{r} | |
# Plot New Cases & ICU Beds Available by County | |
county_viz <- ggplot(data=nys_summary_county, aes(x=actuals.icuBeds.typicalUsageRate, y=actuals.newCases)) + | |
geom_point() + | |
labs(title="New York State COVID-19 Breakdown - By County", subtitle = "Data provided by Covid Act Now - Last 24 Hours", x="ICU Bed Usage Rate", y="New Cases") | |
county_viz | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment