Skip to content

Commit

Permalink
styler
Browse files Browse the repository at this point in the history
  • Loading branch information
dsweber2 committed Jan 23, 2025
1 parent dc6e1bf commit e935edb
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ secondary <- "#f9c80e"
tertiary <- "#177245"
fourth_colour <- "#A393BF"
fifth_colour <- "#2e8edd"
colvec <- c(base = base, primary = primary, secondary = secondary,
tertiary = tertiary, fourth_colour = fourth_colour,
fifth_colour = fifth_colour)
colvec <- c(
base = base, primary = primary, secondary = secondary,
tertiary = tertiary, fourth_colour = fourth_colour,
fifth_colour = fifth_colour
)
library(epiprocess)
suppressMessages(library(tidyverse))
theme_update(legend.position = "bottom", legend.title = element_blank())
Expand All @@ -61,7 +63,7 @@ delphi_pal <- function(n) {
}
scale_fill_delphi <- function(..., aesthetics = "fill") {
discrete_scale(aesthetics = aesthetics, palette = delphi_pal, ...)
}
}
scale_color_delphi <- function(..., aesthetics = "color") {
discrete_scale(aesthetics = aesthetics, palette = delphi_pal, ...)
}
Expand Down Expand Up @@ -124,7 +126,8 @@ cases <- pub_covidcast(
time_type = "day",
geo_type = "state",
time_values = epirange(20200601, 20220101),
geo_values = "*") |>
geo_values = "*"
) |>
select(geo_value, time_value, case_rate = value)
deaths <- pub_covidcast(
Expand All @@ -133,7 +136,8 @@ deaths <- pub_covidcast(
time_type = "day",
geo_type = "state",
time_values = epirange(20200601, 20220101),
geo_values = "*") |>
geo_values = "*"
) |>
select(geo_value, time_value, death_rate = value)
cases_deaths <-
full_join(cases, deaths, by = c("time_value", "geo_value")) |>
Expand All @@ -156,7 +160,7 @@ First, to eliminate some of the noise coming from daily reporting, we do 7 day a

```{r smooth}
cases_deaths <-
cases_deaths |>
cases_deaths |>
group_by(geo_value) |>
epi_slide(
cases_7dav = mean(case_rate, na.rm = TRUE),
Expand All @@ -181,7 +185,8 @@ cases_deaths <-
ungroup() |>
mutate(
death_rate = outlr_death_rate_replacement,
case_rate = outlr_case_rate_replacement) |>
case_rate = outlr_case_rate_replacement
) |>
select(geo_value, time_value, case_rate, death_rate)
cases_deaths
```
Expand All @@ -196,8 +201,8 @@ of the states, noting the actual forecast date:
forecast_date_label <-
tibble(
geo_value = rep(plot_locations, 2),
source = c(rep("case_rate",4), rep("death_rate", 4)),
dates = rep(forecast_date - 7*2, 2 * length(plot_locations)),
source = c(rep("case_rate", 4), rep("death_rate", 4)),
dates = rep(forecast_date - 7 * 2, 2 * length(plot_locations)),
heights = c(rep(150, 4), rep(1.0, 4))
)
processed_data_plot <-
Expand All @@ -209,7 +214,8 @@ processed_data_plot <-
facet_grid(source ~ geo_value, scale = "free") +
geom_vline(aes(xintercept = forecast_date)) +
geom_text(
data = forecast_date_label, aes(x=dates, label = "forecast\ndate", y = heights), size = 3, hjust = "right") +
data = forecast_date_label, aes(x = dates, label = "forecast\ndate", y = heights), size = 3, hjust = "right"
) +
scale_x_date(date_breaks = "3 months", date_labels = "%Y %b") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
```
Expand Down Expand Up @@ -260,7 +266,8 @@ narrow_data_plot <-
facet_grid(source ~ geo_value, scale = "free") +
geom_vline(aes(xintercept = forecast_date)) +
geom_text(
data = forecast_date_label, aes(x=dates, label = "forecast\ndate", y = heights), size = 3, hjust = "right") +
data = forecast_date_label, aes(x = dates, label = "forecast\ndate", y = heights), size = 3, hjust = "right"
) +
scale_x_date(date_breaks = "3 months", date_labels = "%Y %b") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
```
Expand All @@ -278,7 +285,8 @@ forecast_plot <-
epipredict:::plot_bands(
restricted_predictions,
levels = 0.9,
fill = primary) +
fill = primary
) +
geom_point(data = restricted_predictions, aes(y = .data$value), color = secondary)
```
</details>
Expand Down

0 comments on commit e935edb

Please sign in to comment.