R/obtn_covid.R

# obtn_covid_data
#
# county_populations <- obtn_total_population %>%
#   filter(year == 2022)
#
# obtn_covid_data %>%
#   filter(measure == "cases_last_7_days") %>%
#   filter(geography != "Unallocated, OR") %>%
#   left_join(county_populations) %>%
#   mutate(cases_per_100k = value / (population / 100000)) %>%
#   ggplot(aes(x = date,
#              y = cases_per_100k)) +
#   geom_area(fill = tfff_dark_green) +
#   facet_wrap(~geography) +
#   theme_minimal()
#
# obtn_covid_data %>%
#   filter(measure == "cases_last_7_days") %>%
#   filter(geography != "Unallocated, OR") %>%
#   left_join(county_populations) %>%
#   mutate(cases_per_100k = value / (population / 100000)) %>%
#   mutate(week = week(date)) %>%
#   mutate(geography = fct_rev(geography)) %>%
#   ggplot(aes(x = week,
#              y = geography,
#              fill = cases_per_100k)) +
#   geom_tile() +
#   theme_minimal() +
#   scale_fill_gradient(low = tfff_light_green,
#                       high = tfff_dark_green)
# scale_fill_viridis_c()
#
# # JHU data
#
# obtn_covid_cases %>%
#   left_join(county_populations) %>%
#   filter(geography != "Out of OR") %>%
#   filter(geography != "Unassigned") %>%
#   mutate(cases_per_100k = cases / (population / 100000)) %>%
#   ggplot(aes(x = date,
#              y = cases_per_100k)) +
#   geom_area(fill = tfff_dark_green) +
#   facet_wrap(~geography) +
#   theme_minimal()
#
#
# obtn_covid_cases %>%
#   mutate(
#     pd_cases = lag(cases) # Previous Day Cases
#   ) %>%
#   replace_na(list(pd_cases = 0)) %>%
#   mutate(
#     daily_cases = case_when(cases > pd_cases ~ cases - pd_cases,
#                             TRUE ~ 0)
#   ) %>%
#   filter(date > as.Date("2021-01-01")) %>%
#   mutate(roll_cases = zoo::rollmean(daily_cases, k = 7, fill = NA)) %>%
#   left_join(county_populations) %>%
#   filter(geography != "Out of OR") %>%
#   filter(geography != "Unassigned") %>%
#   mutate(cases_per_100k = daily_cases / (population / 100000)) %>%
#   ggplot(aes(x = date,
#              y = cases_per_100k)) +
#   geom_area(fill = tfff_dark_green) +
#   scale_x_date(
#     date_breaks = "3 months",
#     label = label_date_short(),
#     expand = expansion(mult = c(0.01, 0))
#   ) +
#   facet_wrap(~geography) +
#   theme_minimal() +
#   labs(x = NULL,
#        y = NULL) +
#   theme(panel.grid.minor.x = element_blank(),
#         panel.grid.major.x = element_blank(),
#         panel.grid.minor.y = element_blank())
#
# obtn_covid_cases %>%
#   mutate(
#     pd_cases = lag(cases) # Previous Day Cases
#   ) %>%
#   replace_na(list(pd_cases = 0)) %>%
#   mutate(
#     daily_cases = case_when(cases > pd_cases ~ cases - pd_cases,
#                             TRUE ~ 0)
#   ) %>%
#   filter(date > as.Date("2021-01-01")) %>%
#   mutate(roll_cases = zoo::rollmean(daily_cases, k = 7, fill = NA)) %>%
#   left_join(county_populations) %>%
#   filter(geography != "Out of OR") %>%
#   filter(geography != "Unassigned") %>%
#   mutate(cases_per_100k = daily_cases / (population / 100000)) %>%
#   arrange(desc(cases_per_100k)) %>%
#   mutate(geography = fct_rev(geography)) %>%
#   ggplot(aes(x = date,
#              y = geography,
#              fill = cases_per_100k)) +
#   geom_tile() +
#   theme_minimal() +
#   scale_x_date(
#     date_breaks = "1 month",
#     label = label_date_short(),
#     expand = expansion(mult = c(0.01, 0))
#   ) +
#   scale_fill_gradient(low = tfff_light_green,
#                       high = tfff_dark_green)
# scale_fill_viridis_c()
rfortherestofus/obtn documentation built on Feb. 10, 2025, 1:30 a.m.