#installing zoo package

library(tidyverse)
library(knitr)
library(readxl)
library(zoo)

#this adds all of these packages into our library for this project

#Question 1:

url = 'https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv'

covid = read_csv(url)

#Importing data via url

url = 'https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv'

covid = read_csv(url)

#Filtering our data to only generate results for New Cases each day to only California Counties

#Dataframe showing Cumulative cases in descending order

covid2 = covid %>%  
  filter(state == ("California")) %>% 
  group_by(county) %>% 
  mutate(newCases = cases - lag(cases)) %>%
  ungroup() %>% 
  filter(date == max(date))%>%
  select(state, county, cases, newCases) %>% 
  slice_max(cases, n = 5)

#Dataframe showing new cases in descending order

covid3 = covid %>%  
  filter(state == ("California")) %>% 
  group_by(county) %>% 
  mutate(newCases = cases - lag(cases)) %>%
  ungroup() %>% 
  filter(date == max(date))%>%
  select(state, county, cases, newCases) %>% 
  slice_max(newCases, n = 5)

#shows our data table with captions for how to interpret the results.

knitr::kable(covid3, 
             caption = "Most New Cases California Counties",
             col.names = c("State", "County", "Cases", "New Cases"))
Most New Cases California Counties
State County Cases New Cases
California Los Angeles 253985 809
California San Diego 42742 265
California Orange 52121 185
California Fresno 27076 159
California San Bernardino 50699 156
knitr::kable(covid2, 
             caption = "Most Cumulative Cases California Counties",
             col.names = c("State", "County", "Cases", "New Cases"))
Most Cumulative Cases California Counties
State County Cases New Cases
California Los Angeles 253985 809
California Riverside 55073 0
California Orange 52121 185
California San Bernardino 50699 156
California San Diego 42742 265

#allows us to read excel files for the data we are about to import.

library(readxl)

#loading the downloaded excel data

library(readxl)
Pop <- read_excel("~/github/geog-176A-labs/data/PopulationEstimates.xls", skip = 2)
Pop2 = Pop %>%
  select(fips = FIPStxt, state = State, Area_Name, pop_2019 = POP_ESTIMATE_2019) %>%
  right_join(covid, pop, by = "fips") %>%
  filter(date >= max(date)-13, state.y == "California") %>% 
  group_by(county) %>%
  mutate(cumul_per_cap = sum(cases) / pop_2019) %>%
  mutate(new_cases_per_cap = sum(cases - lag(cases), na.rm= TRUE)/ pop_2019) %>%
  select(county, cumul_per_cap, new_cases_per_cap)

(most_new_cases_per_cap = Pop2 %>%
  slice_max(new_cases_per_cap, n = 5) %>%
  select(county, cumul_per_cap))
## # A tibble: 812 x 2
## # Groups:   county [58]
##    county  cumul_per_cap
##    <chr>           <dbl>
##  1 Alameda         0.161
##  2 Alameda         0.161
##  3 Alameda         0.161
##  4 Alameda         0.161
##  5 Alameda         0.161
##  6 Alameda         0.161
##  7 Alameda         0.161
##  8 Alameda         0.161
##  9 Alameda         0.161
## 10 Alameda         0.161
## # … with 802 more rows
(most_cumul_per_cap = Pop2 %>%
    slice_max(cumul_per_cap, n = 5) %>%
  select(county, cumul_per_cap))
## # A tibble: 812 x 2
## # Groups:   county [58]
##    county  cumul_per_cap
##    <chr>           <dbl>
##  1 Alameda         0.161
##  2 Alameda         0.161
##  3 Alameda         0.161
##  4 Alameda         0.161
##  5 Alameda         0.161
##  6 Alameda         0.161
##  7 Alameda         0.161
##  8 Alameda         0.161
##  9 Alameda         0.161
## 10 Alameda         0.161
## # … with 802 more rows
library(formattable)

knitr::kable(most_new_cases_per_cap,
             caption = "Most New Cases Per Capita: California",
             col.names = c("County", "New Cases Per Capita"),
             format.args = list(big.mark = ","))
Most New Cases Per Capita: California
County New Cases Per Capita
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
knitr::kable(most_cumul_per_cap,
             caption = "Most Cumulative Cases Per Capita: California",
             col.names = c("County", "Cumulative Cases Per Capita"),
             format.args = list(big.mark = ","))
Most Cumulative Cases Per Capita: California
County Cumulative Cases Per Capita
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alameda 0.1612555
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Alpine 0.0248007
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Amador 0.0934544
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Butte 0.1526147
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Calaveras 0.0838906
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Colusa 0.3080707
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Contra Costa 0.1774108
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
Del Norte 0.0630303
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
El Dorado 0.0730128
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Fresno 0.3674313
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Glenn 0.2353397
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Humboldt 0.0432877
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Imperial 0.8507629
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Inyo 0.1319364
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kern 0.4679372
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Kings 0.6176017
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lake 0.0781692
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Lassen 0.3303569
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Los Angeles 0.3460146
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Madera 0.3547643
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Marin 0.3426279
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mariposa 0.0601639
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Mendocino 0.1218804
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Merced 0.4198358
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Modoc 0.0262414
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Mono 0.1572279
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Monterey 0.2745213
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Napa 0.1519631
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Nevada 0.0652298
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Orange 0.2230194
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Placer 0.1114857
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Plumas 0.0304674
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Riverside 0.3069819
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
Sacramento 0.1728247
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Benito 0.2627213
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Bernardino 0.3168546
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Diego 0.1706057
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Francisco 0.1574581
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Joaquin 0.3389355
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Luis Obispo 0.1539220
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
San Mateo 0.1578519
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Barbara 0.2640140
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Clara 0.1343900
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Santa Cruz 0.0989448
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Shasta 0.0459351
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Sierra 0.0279534
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Siskiyou 0.0471531
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Solano 0.1783497
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Sonoma 0.1788824
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Stanislaus 0.3913304
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Sutter 0.2155799
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Tehama 0.0959837
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Trinity 0.0166056
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tulare 0.4424200
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Tuolumne 0.0509380
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Ventura 0.1866583
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yolo 0.1616689
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
Yuba 0.1785605
names(Pop)
##   [1] "FIPStxt"                         "State"                          
##   [3] "Area_Name"                       "Rural-urban_Continuum Code_2003"
##   [5] "Rural-urban_Continuum Code_2013" "Urban_Influence_Code_2003"      
##   [7] "Urban_Influence_Code_2013"       "Economic_typology_2015"         
##   [9] "CENSUS_2010_POP"                 "ESTIMATES_BASE_2010"            
##  [11] "POP_ESTIMATE_2010"               "POP_ESTIMATE_2011"              
##  [13] "POP_ESTIMATE_2012"               "POP_ESTIMATE_2013"              
##  [15] "POP_ESTIMATE_2014"               "POP_ESTIMATE_2015"              
##  [17] "POP_ESTIMATE_2016"               "POP_ESTIMATE_2017"              
##  [19] "POP_ESTIMATE_2018"               "POP_ESTIMATE_2019"              
##  [21] "N_POP_CHG_2010"                  "N_POP_CHG_2011"                 
##  [23] "N_POP_CHG_2012"                  "N_POP_CHG_2013"                 
##  [25] "N_POP_CHG_2014"                  "N_POP_CHG_2015"                 
##  [27] "N_POP_CHG_2016"                  "N_POP_CHG_2017"                 
##  [29] "N_POP_CHG_2018"                  "N_POP_CHG_2019"                 
##  [31] "Births_2010"                     "Births_2011"                    
##  [33] "Births_2012"                     "Births_2013"                    
##  [35] "Births_2014"                     "Births_2015"                    
##  [37] "Births_2016"                     "Births_2017"                    
##  [39] "Births_2018"                     "Births_2019"                    
##  [41] "Deaths_2010"                     "Deaths_2011"                    
##  [43] "Deaths_2012"                     "Deaths_2013"                    
##  [45] "Deaths_2014"                     "Deaths_2015"                    
##  [47] "Deaths_2016"                     "Deaths_2017"                    
##  [49] "Deaths_2018"                     "Deaths_2019"                    
##  [51] "NATURAL_INC_2010"                "NATURAL_INC_2011"               
##  [53] "NATURAL_INC_2012"                "NATURAL_INC_2013"               
##  [55] "NATURAL_INC_2014"                "NATURAL_INC_2015"               
##  [57] "NATURAL_INC_2016"                "NATURAL_INC_2017"               
##  [59] "NATURAL_INC_2018"                "NATURAL_INC_2019"               
##  [61] "INTERNATIONAL_MIG_2010"          "INTERNATIONAL_MIG_2011"         
##  [63] "INTERNATIONAL_MIG_2012"          "INTERNATIONAL_MIG_2013"         
##  [65] "INTERNATIONAL_MIG_2014"          "INTERNATIONAL_MIG_2015"         
##  [67] "INTERNATIONAL_MIG_2016"          "INTERNATIONAL_MIG_2017"         
##  [69] "INTERNATIONAL_MIG_2018"          "INTERNATIONAL_MIG_2019"         
##  [71] "DOMESTIC_MIG_2010"               "DOMESTIC_MIG_2011"              
##  [73] "DOMESTIC_MIG_2012"               "DOMESTIC_MIG_2013"              
##  [75] "DOMESTIC_MIG_2014"               "DOMESTIC_MIG_2015"              
##  [77] "DOMESTIC_MIG_2016"               "DOMESTIC_MIG_2017"              
##  [79] "DOMESTIC_MIG_2018"               "DOMESTIC_MIG_2019"              
##  [81] "NET_MIG_2010"                    "NET_MIG_2011"                   
##  [83] "NET_MIG_2012"                    "NET_MIG_2013"                   
##  [85] "NET_MIG_2014"                    "NET_MIG_2015"                   
##  [87] "NET_MIG_2016"                    "NET_MIG_2017"                   
##  [89] "NET_MIG_2018"                    "NET_MIG_2019"                   
##  [91] "RESIDUAL_2010"                   "RESIDUAL_2011"                  
##  [93] "RESIDUAL_2012"                   "RESIDUAL_2013"                  
##  [95] "RESIDUAL_2014"                   "RESIDUAL_2015"                  
##  [97] "RESIDUAL_2016"                   "RESIDUAL_2017"                  
##  [99] "RESIDUAL_2018"                   "RESIDUAL_2019"                  
## [101] "GQ_ESTIMATES_BASE_2010"          "GQ_ESTIMATES_2010"              
## [103] "GQ_ESTIMATES_2011"               "GQ_ESTIMATES_2012"              
## [105] "GQ_ESTIMATES_2013"               "GQ_ESTIMATES_2014"              
## [107] "GQ_ESTIMATES_2015"               "GQ_ESTIMATES_2016"              
## [109] "GQ_ESTIMATES_2017"               "GQ_ESTIMATES_2018"              
## [111] "GQ_ESTIMATES_2019"               "R_birth_2011"                   
## [113] "R_birth_2012"                    "R_birth_2013"                   
## [115] "R_birth_2014"                    "R_birth_2015"                   
## [117] "R_birth_2016"                    "R_birth_2017"                   
## [119] "R_birth_2018"                    "R_birth_2019"                   
## [121] "R_death_2011"                    "R_death_2012"                   
## [123] "R_death_2013"                    "R_death_2014"                   
## [125] "R_death_2015"                    "R_death_2016"                   
## [127] "R_death_2017"                    "R_death_2018"                   
## [129] "R_death_2019"                    "R_NATURAL_INC_2011"             
## [131] "R_NATURAL_INC_2012"              "R_NATURAL_INC_2013"             
## [133] "R_NATURAL_INC_2014"              "R_NATURAL_INC_2015"             
## [135] "R_NATURAL_INC_2016"              "R_NATURAL_INC_2017"             
## [137] "R_NATURAL_INC_2018"              "R_NATURAL_INC_2019"             
## [139] "R_INTERNATIONAL_MIG_2011"        "R_INTERNATIONAL_MIG_2012"       
## [141] "R_INTERNATIONAL_MIG_2013"        "R_INTERNATIONAL_MIG_2014"       
## [143] "R_INTERNATIONAL_MIG_2015"        "R_INTERNATIONAL_MIG_2016"       
## [145] "R_INTERNATIONAL_MIG_2017"        "R_INTERNATIONAL_MIG_2018"       
## [147] "R_INTERNATIONAL_MIG_2019"        "R_DOMESTIC_MIG_2011"            
## [149] "R_DOMESTIC_MIG_2012"             "R_DOMESTIC_MIG_2013"            
## [151] "R_DOMESTIC_MIG_2014"             "R_DOMESTIC_MIG_2015"            
## [153] "R_DOMESTIC_MIG_2016"             "R_DOMESTIC_MIG_2017"            
## [155] "R_DOMESTIC_MIG_2018"             "R_DOMESTIC_MIG_2019"            
## [157] "R_NET_MIG_2011"                  "R_NET_MIG_2012"                 
## [159] "R_NET_MIG_2013"                  "R_NET_MIG_2014"                 
## [161] "R_NET_MIG_2015"                  "R_NET_MIG_2016"                 
## [163] "R_NET_MIG_2017"                  "R_NET_MIG_2018"                 
## [165] "R_NET_MIG_2019"
dim(Pop)
## [1] 3273  165
nrow(Pop)
## [1] 3273
#last14days =  Pop2 %>%
  #filter(date > max(date) - 13) %>%
  #group_by(county, pop_2019)%>%
  #summarise(newCases = sum(newCases)) %>%
  #ungroup() %>%
  #mutate(casePer100 = newCases / (pop_2019 / 100000)) %>%
  #filter(casePer100 <= 100) %>%
  #pull(county)

#could not get code to run

#Question 2

#filters the data like covid2, but now this data also includes values for New York, Florida and Louisiana

covid3 = covid %>%  
  filter(state == c("California", "New York", "Florida", "Louisiana")) %>% 
  group_by(county) %>% 
  mutate(newCases = cases - lag(cases)) %>%
  ungroup() %>% 
  filter(date == max(date))%>%
  select(state, county, cases, newCases)
Most_cumulative2 = covid3[order(-covid3$cases),]

Most_new2 = covid3[order(-covid3$newCases),]

covid3 %>% 
  group_by(state) %>% 
  mutate(roll_mean = rollmean(cases, 2, na.pad = T))
## # A tibble: 64 x 5
## # Groups:   state [4]
##    state      county        cases newCases roll_mean
##    <chr>      <chr>         <dbl>    <dbl>     <dbl>
##  1 California Alpine            2        0      246.
##  2 California Colusa          489        0    13782.
##  3 California Fresno        27076      159    13626.
##  4 California Inyo            177        1      452 
##  5 California Lassen          727        0      401 
##  6 California Mariposa         75        0      119 
##  7 California Mono            163        0    26142 
##  8 California Orange        52121      185    36152 
##  9 California Sacramento    20183      121    15244 
## 10 California San Francisco 10305       39     9474.
## # … with 54 more rows
Most_cumulative2 = covid3[order(-covid3$cases),]


Most_new2 = covid3[order(-covid3$newCases),]


#ggplot(data = Most_new2, aes(x = newCases, y = roll_mean)) +
  #geom_point(aes(color = county, size = cases)) +
  #labs(title = "Roll Mean of Corona Virus Counts as a Fucntion of Daily New Cases Per State", x = "Daily New Cases", y = "Roll Mean", color = "", size = "Cases") +
  #facet_wrap(~state)+
  #theme_bw()

#could not get code to run