Skip to content

Instantly share code, notes, and snippets.

@vikjam
Last active April 5, 2020 16:54
Show Gist options
  • Select an option

  • Save vikjam/f91acfb1b825c0345fc7f4a7c1f6c75e to your computer and use it in GitHub Desktop.

Select an option

Save vikjam/f91acfb1b825c0345fc7f4a7c1f6c75e to your computer and use it in GitHub Desktop.

Revisions

  1. vikjam revised this gist Apr 5, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions visualize.r
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ library(hrbrthemes)
    p_cases_vs_pop <- ggplot(cases_pop, aes(x = population, y = confirmed_cases)) +
    geom_point() +
    labs(x="Population", y="Confirmed cases",
    title="Population versus COVID-19 Cases, by ZIP Code",
    subtitle="Restricted to San Diego County",
    caption="Updated April 4, 2020") +
    title="Population versus COVID-19 Cases, by ZIP Code",
    subtitle="Restricted to San Diego County",
    caption="Updated April 4, 2020") +
    theme_ipsum_rc()
  2. vikjam revised this gist Apr 5, 2020. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions visualize.r
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    library(ggplot2)
    library(hrbrthemes)

    p_cases_vs_pop <- ggplot(cases_pop, aes(x = population, y = confirmed_cases)) +
    geom_point() +
    labs(x="Population", y="Confirmed cases",
    title="Population versus COVID-19 Cases, by ZIP Code",
    subtitle="Restricted to San Diego County",
    caption="Updated April 4, 2020") +
    theme_ipsum_rc()
  3. vikjam revised this gist Apr 5, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion append_population.r
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,9 @@
    library(readr)
    library(tidycensus)
    library(dplyr)
    library(stringr)

    cases <- read.csv("")
    cases <- read_csv("https://gist.github.com/vikjam/f91acfb1b825c0345fc7f4a7c1f6c75e/raw/a58fc598ca58e36c7d2960cf1c59d3f314a2b527/cases_by_zip.csv")

    acs_population <- get_acs(geography = "zcta",
    variables = c(population = "B01001_001"),
    @@ -11,3 +12,4 @@ acs_population <- get_acs(geography = "zcta",
    select(GEOID, estimate) %>%
    rename(zip = GEOID, population = estimate)

    cases_pop <- inner_join(cases, acs_population, by = "zip")
  4. vikjam revised this gist Apr 5, 2020. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions append_population.r
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    library(tidycensus)
    library(dplyr)
    library(stringr)

    cases <- read.csv("")

    acs_population <- get_acs(geography = "zcta",
    variables = c(population = "B01001_001"),
    year = 2018) %>%
    filter(str_sub(GEOID, 1, 2) %in% c("91", "92")) %>%
    select(GEOID, estimate) %>%
    rename(zip = GEOID, population = estimate)

  5. vikjam revised this gist Apr 5, 2020. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    #
    # COVID-19 Cases (San Diego County, by ZIP Code) - Updated April 4, 2020

    Sources:
    - [San Diego County](https://www.sandiegocounty.gov/content/dam/sdc/hhsa/programs/phs/Epidemiology/COVID-19%20Summary%20of%20Cases%20by%20Zip%20Code.pdf)
    - [NBC San Diego](https://www.nbcsandiego.com/news/local/san-diego-county-coronavirus-cases-by-zip-code/2297177/)
    - [NBC San Diego](https://www.nbcsandiego.com/news/local/san-diego-county-coronavirus-cases-by-zip-code/2297177/)

    > County officials stressed the presence of cases, or lack thereof, should not affect how people operate during the coronavirus pandemic.
    > Staying at home, practicing social distancing and washing your hands are just some practices to maintain, regardless of the number of cases reported in your community.
    > The number of people actually infected with the disease is likely much higher than reported numbers because not everyone needs to be tested, including in some cases, the close contacts of positive patients who are usually presumed to have the disease.
  6. vikjam revised this gist Apr 5, 2020. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    #

    Sources:
    - [San Diego County](https://www.sandiegocounty.gov/content/dam/sdc/hhsa/programs/phs/Epidemiology/COVID-19%20Summary%20of%20Cases%20by%20Zip%20Code.pdf)
    - [NBC San Diego](https://www.nbcsandiego.com/news/local/san-diego-county-coronavirus-cases-by-zip-code/2297177/)
  7. vikjam revised this gist Apr 5, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cases_by_zip.csv
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    zip,confirmed_cases
    "91901",1
    "91902",10
    "91909",1
  8. vikjam created this gist Apr 5, 2020.
    98 changes: 98 additions & 0 deletions cases_by_zip.csv
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,98 @@
    "91901",1
    "91902",10
    "91909",1
    "91910",28
    "91911",24
    "91913",21
    "91914",3
    "91915",8
    "91916",1
    "91932",3
    "91935",1
    "91941",8
    "91942",12
    "91945",13
    "91950",18
    "91977",24
    "91978",3
    "92004",1
    "92007",4
    "92008",8
    "92009",16
    "92010",9
    "92011",6
    "92014",12
    "92019",26
    "92020",39
    "92021",28
    "92024",23
    "92025",12
    "92026",7
    "92027",6
    "92028",6
    "92029",9
    "92037",31
    "92039",1
    "92040",9
    "92054",8
    "92056",11
    "92057",7
    "92058",5
    "92061",2
    "92064",13
    "92065",7
    "92066",2
    "92067",12
    "92069",7
    "92071",14
    "92075",4
    "92078",11
    "92081",10
    "92082",3
    "92083",2
    "92084",10
    "92085",1
    "92088",0
    "92091",2
    "92092",0
    "92093",4
    "92101",29
    "92102",14
    "92103",65
    "92104",34
    "92105",29
    "92106",9
    "92107",3
    "92108",14
    "92109",24
    "92110",15
    "92111",15
    "92113",29
    "92114",24
    "92115",21
    "92116",31
    "92117",19
    "92118",4
    "92119",6
    "92120",16
    "92121",3
    "92122",13
    "92123",16
    "92124",11
    "92126",22
    "92127",19
    "92128",25
    "92129",18
    "92130",21
    "92131",6
    "92136",2
    "92139",18
    "92145",1
    "92147",0
    "92154",28
    "92159",0
    "92161",2
    "92168",1
    "92173",12
    "92196",1
    "Unknown",22