This report was current as of 9/05/2020

In this lab:

- manipulation and examination of New York Times COVID cases dataset
- creating visualizations and tables to report findings
- scaling by population and calculation of rolling averages


Data:

- dataset with cumulative counts of coronavirus cases and deaths for each geography
- will use the historic (final counts at end of each day), county level data which is stored as an updating CSV

Libraries

data wrangling tools
  • library(tidyverse)
read files
  • library(readxl)
rolling averages
  • library(zoo)
plots and tables
  • library(knitr)

The California Department of Public Health maintains a current watch list of counties that are being monitored for worsening coronavirus trends. There are six criteria used to place counties on the watch list:

1. Doing fewer than 150 tests per 100,000 residents daily (over a 7-day average)
2. More than 100 new cases per 100,000 residents over the past 14 days…
3. 25 new cases per 100,000 residents and an 8% test positivity rate
4. 10% or greater increase in COVID-19 hospitalized patients over the past 3 days
5. Fewer than 20% of ICU beds available
6. Fewer than 25% ventilators available

Here, condition 2 will be examined with tables containing:

– total NEW cases in the 5 worst counties
– cumulative cases in the 5 worst counties
– number of unsafe counties

addednewcases <- coviddata %>% # filter data by state of interest
  filter(state == stateofinterest) %>%
  group_by(county, date) %>%
  summarise(cases = sum(cases), fips) %>%
  mutate(newCases = cases - lag(cases)) %>% # creates new column with daily new cases
  ungroup()

mostnewcases <- addednewcases %>% # finds top 5 counties with most new cases per day
    filter(date == max(date)) %>%
    slice_max(newCases, n = 5) %>%
    select(county, newCases)

mostcumulativecases <- addednewcases %>% # finds top 5 counties with most cumulative cases
  filter(date == max(date)) %>%
  slice_max(cases, n = 5) %>%
  select(county, cases)

Los Angeles, San Bernardino, San Diego, Fresno and Orange County are the counties with the most new cases reported daily. Both Los Angeles and San Bernado reported over a thousand.

Most New Cases California Counties
County New Cases
Los Angeles 809
San Diego 265
Orange 185
Fresno 159
San Bernardino 156

Los Angeles, Riverside, Orange, San Bernardino, and San Diego are the counties with the most total reported cases, this could be due to be being the largest 5 counties in California. Los Angeles is the only reporting more than 50,000 cases currently.

Most Cumulative Cases California Counties
County Total Cases
Los Angeles 253,985
Riverside 55,073
Orange 52,121
San Bernardino 50,699
San Diego 42,742

Per Capita Calculations

PopulationEstimates <- read_excel("~/github/geog-176A-labs/data/PopulationEstimates.xls", skip = 2)
# dim(PopulationEstimates) # examine dimensions of excel file
# head(PopulationEstimates,5)

populationestimates <- PopulationEstimates %>% # select only necessary columns
  select(fips = "FIPStxt", state = "State", Area_Name, pop2019 = "POP_ESTIMATE_2019")


CovidandPopulation <- addednewcases %>%
  inner_join(populationestimates, by = "fips" ) # join to previous data


mostnewcasespc <- CovidandPopulation %>% # finds top 5 counties with daily new cases per capita
  filter(date == max(date)) %>%
  group_by(county) %>%
  mutate(casepercap = cases / pop2019) %>%
  ungroup() %>%
  slice_max(casepercap, n = 5) %>%
  select(county, casepercap)


mostcumulativecasespc <-CovidandPopulation %>% # finds top 5 counties with cumulative cases per capita
  filter(date == max(date)) %>%
  group_by(county) %>%
  mutate(newcasepercap = newCases / pop2019) %>%
  ungroup() %>%
  slice_max(newcasepercap, n = 5) %>%
  select(county, newcasepercap)

Examining the same data with respect to population size, it can be seen that the 5 highest counties of new daily cases per capita are Imperial, Kings, Kern, Tulare and Merced County. While most total cases per capita are San Bernardino, Stanislaus, Kings, Fresno, and Marin County.

Most New Cases California Counties Per Capita
County New Cases Per Capita
Imperial 0.0622134
Kings 0.0464038
Kern 0.0341423
Tulare 0.0324199
Merced 0.0307584

Most Cumulative Cases California Counties Per Capita
County Total Cases Per Capita
Kings 0.0002615
San Benito 0.0002388
Monterey 0.0002027
Lake 0.0001708
Fresno 0.0001591

numofdays <- 14

greaterthan100 <- CovidandPopulation %>%
  filter(date > (max(date) - numofdays)) %>%
  group_by(county, date) %>%
  summarise(ncases =  100000 * (sum(newCases) / pop2019)) %>%
  filter(ncases > 100)

2 counties have more than 100 cases per 100,000 residents in the past 14 days, that leaves 55 counties deemed as safe.

California Counties with > 100 cases within 2 weeks
County Date Cases Per 100,000 Residents
Imperial 2020-09-04 125.8174
Kings 2020-09-04 171.3090

Examining impact of scale on COVID cases

statesofinterest <- c("New York", "California", "Louisiana","Florida")

coviddatastate <- coviddata %>%
  filter(state %in% statesofinterest) %>%
  group_by(state, date) %>%
  summarise(cases = sum(cases)) %>%
  # creates new column withe daily new cases
  mutate(newCases = cases - lag(cases),  roll7 = rollmean(newCases, 7, fill = NA, align="right")) %>%
  ungroup()

  coviddatastate %>%
  ggplot(aes(x = date, y = newCases)) +  geom_col(aes(y = newCases, col = state))+
  geom_line(aes(col = state)) + geom_line(aes(y = roll7), size = 1) +
  facet_wrap(~state, nrow = 2) + ggthemes::theme_economist_white()+ ggthemes::scale_color_few() +
  theme(legend.position = "bottom") +
  theme(legend.position = "NA") +
  labs(title = "Daily new cases by State", y = "Daily New Count", x = "Date",
       caption = "Lab 02")


coviddatastate %>%
  inner_join(populationestimates, by = c("state" = "Area_Name") ) %>%
  group_by(state, date) %>%
  summarise(newcases = sum(newCases), pop2019, .groups = "drop") %>%
  mutate(newcasepercap = (newcases / pop2019), roll7 = rollmean(newcasepercap, 7, fill = NA, align="right"))%>%
  ggplot(aes(x = date, y = newcasepercap)) +
  geom_col(aes(y = newcasepercap, col = state))+
  geom_line(aes(col = state)) + geom_line(aes(y = roll7), size = 1)+
  facet_wrap(~state, nrow = 2) + ggthemes::theme_economist_white() + ggthemes::scale_color_few() +
  theme(legend.position = "none") +
  labs(title = "Daily new cases Per Capita by State", y = "Daily New Count Per Capita", x = "Date",
       caption = "Lab 02")


This graph was scaled by population, and it can be seen that Louisiana’s situation is more dire while California’s appears better. California has the largest population among these states and after scaling, it can be seen that they have had the smallest reported spike in daily cases. New York and Florida are close together in population and appear to have a similar sized spike in daily cases. Whereas before the scaling it appeared Florida had the largest spike, and California and New York’s was similar. Although New York’s was in April while Florida’s happened in July. Louisiana has the smallest population by far with roughly 4.6 million (New York, California and Florida have a population greater than 19 million) but, after scaling, has the largest spike in daily new cases per capita.