Libraries

library(dplyr) 
library(ggplot2)
library(tidyverse)
library(zoo)
library(knitr)
library(readxl)

Getting Data

url = 'https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv'
read_csv(url)
## # A tibble: 531,243 x 6
##    date       county      state      fips  cases deaths
##    <date>     <chr>       <chr>      <chr> <dbl>  <dbl>
##  1 2020-01-21 Snohomish   Washington 53061     1      0
##  2 2020-01-22 Snohomish   Washington 53061     1      0
##  3 2020-01-23 Snohomish   Washington 53061     1      0
##  4 2020-01-24 Cook        Illinois   17031     1      0
##  5 2020-01-24 Snohomish   Washington 53061     1      0
##  6 2020-01-25 Orange      California 06059     1      0
##  7 2020-01-25 Cook        Illinois   17031     1      0
##  8 2020-01-25 Snohomish   Washington 53061     1      0
##  9 2020-01-26 Maricopa    Arizona    04013     1      0
## 10 2020-01-26 Los Angeles California 06037     1      0
## # … with 531,233 more rows
source = "/Users/xingxin/Github/geog176a-lab2/data/"
covid<-read_csv(url)
head(covid)
## # A tibble: 6 x 6
##   date       county    state      fips  cases deaths
##   <date>     <chr>     <chr>      <chr> <dbl>  <dbl>
## 1 2020-01-21 Snohomish Washington 53061     1      0
## 2 2020-01-22 Snohomish Washington 53061     1      0
## 3 2020-01-23 Snohomish Washington 53061     1      0
## 4 2020-01-24 Cook      Illinois   17031     1      0
## 5 2020-01-24 Snohomish Washington 53061     1      0
## 6 2020-01-25 Orange    California 06059     1      0

Question 1 : Collecting Data

Most Cumulative Cases California Counties
County cumulative Cases
Los Angeles 253985
Riverside 55073
Orange 52121
San Bernardino 50699
San Diego 42742
Most New Cases California Counties
County New Cases
Los Angeles 809
San Diego 265
Orange 185
Fresno 159
San Bernardino 156
Most Cumulative Cases California Counties Per Capita
County cumulative Cases Per Capita
Imperial 0.0622134
Kings 0.0464038
Kern 0.0341423
Tulare 0.0324199
Merced 0.0307584
# the 5 counties with the most NEW cases per capita
most_new_cases_pc = dat2 %>% 
  mutate(newCases_pc = newCases/POP_ESTIMATE_2019) %>%
  slice_max(newCases_pc, n = 5) %>% 
  select(county, newCases_pc)

knitr::kable(most_new_cases_pc, 
             caption = "Most New Cases California Counties Per Capit",
             col.names = c("County", "New Cases Per Capit"))
Most New Cases California Counties Per Capit
County New Cases Per Capit
Kings 0.0002615
San Benito 0.0002388
Monterey 0.0002027
Lake 0.0001708
Fresno 0.0001591

Results of California

  1. the total number of cases: 7.63389^{5}

  2. the total number of new cases: 2808

  3. the total number of the total number of safe counties : 21

Question 2 : Four States

The absolute value of new cases in Louisiana is much lower than the other three states. However, the new cases per capita in Louisiana is close to the other states. The possible reason is that Louisiana has a much smaller populaition compared with other states.