View source: R/get_genpop_covid.R
get_genpop_covid | R Documentation |
Pulls data from the NYT github page on COVID cases and deaths for a county and then merges alongside a population number from the 2019 Census population estimates for that county to use for rate calculation.
get_genpop_covid(county, state = NULL)
county |
either a 5 digit fips code (safer) or a county name |
state |
a state name or abbreviation if a county name was provided |
a data frame with the following columns: Date, County, State, FIPS, General.Confirmed, General.Deaths, General.Population
## Not run: # get data from Orange county, North Carolina get_genpop_covid(county = "Orange", state = "NC") # get data from los angeles by fips code get_genpop_covid(county = "06037") get CA hist data ca_df <- read_scrape_data(TRUE, state = "California") # look only at SATF satf_df <- ca_df %>% filter(Name == "SUBSTANCE ABUSE TREATMENT FACILITY") # get the corresponding county data county_df <- get_genpop_covid(first(satf_df$County.FIPS)) # make the plot comparing prison vs general population county_df %>% # get rid of potential conflicting columns select(Date, tidyr::starts_with("General")) %>% right_join(satf_df) %>% mutate(`Prisoner\nPopulation` = Residents.Confirmed / Population.Feb20) %>% mutate(`King County\nPopulation` = General.Confirmed / General.Population2019) %>% select(Date, `Prisoner\nPopulation`, `King County\nPopulation`) %>% tidyr::pivot_longer(-Date) %>% mutate(name = forcats::fct_rev(name)) %>% ggplot(aes(x = Date, y = value, color = name, fill = name)) + geom_area(alpha=.5, size = 1.5, position = position_dodge()) + theme_behindbars() + scale_color_bbdiscrete() + labs(y = "Proportion\nInfected", color = "", fill = "") + ylim(c(0,.65)) + ggtitle( "Substance Abuse Treatment Facility Outbreak", "Comparing COVID Outbreaks in Prison and the Surrounding Area" ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.