@@ -49,9 +49,11 @@ secondary <- "#f9c80e"
49
49
tertiary <- "#177245"
50
50
fourth_colour <- "#A393BF"
51
51
fifth_colour <- "#2e8edd"
52
- colvec <- c(base = base, primary = primary, secondary = secondary,
53
- tertiary = tertiary, fourth_colour = fourth_colour,
54
- fifth_colour = fifth_colour)
52
+ colvec <- c(
53
+ base = base, primary = primary, secondary = secondary,
54
+ tertiary = tertiary, fourth_colour = fourth_colour,
55
+ fifth_colour = fifth_colour
56
+ )
55
57
library(epiprocess)
56
58
suppressMessages(library(tidyverse))
57
59
theme_update(legend.position = "bottom", legend.title = element_blank())
@@ -61,7 +63,7 @@ delphi_pal <- function(n) {
61
63
}
62
64
scale_fill_delphi <- function(..., aesthetics = "fill") {
63
65
discrete_scale(aesthetics = aesthetics, palette = delphi_pal, ...)
64
- }
66
+ }
65
67
scale_color_delphi <- function(..., aesthetics = "color") {
66
68
discrete_scale(aesthetics = aesthetics, palette = delphi_pal, ...)
67
69
}
@@ -124,7 +126,8 @@ cases <- pub_covidcast(
124
126
time_type = "day",
125
127
geo_type = "state",
126
128
time_values = epirange(20200601, 20220101),
127
- geo_values = "*") |>
129
+ geo_values = "*"
130
+ ) |>
128
131
select(geo_value, time_value, case_rate = value)
129
132
130
133
deaths <- pub_covidcast(
@@ -133,7 +136,8 @@ deaths <- pub_covidcast(
133
136
time_type = "day",
134
137
geo_type = "state",
135
138
time_values = epirange(20200601, 20220101),
136
- geo_values = "*") |>
139
+ geo_values = "*"
140
+ ) |>
137
141
select(geo_value, time_value, death_rate = value)
138
142
cases_deaths <-
139
143
full_join(cases, deaths, by = c("time_value", "geo_value")) |>
@@ -156,7 +160,7 @@ First, to eliminate some of the noise coming from daily reporting, we do 7 day a
156
160
157
161
``` {r smooth}
158
162
cases_deaths <-
159
- cases_deaths |>
163
+ cases_deaths |>
160
164
group_by(geo_value) |>
161
165
epi_slide(
162
166
cases_7dav = mean(case_rate, na.rm = TRUE),
@@ -181,7 +185,8 @@ cases_deaths <-
181
185
ungroup() |>
182
186
mutate(
183
187
death_rate = outlr_death_rate_replacement,
184
- case_rate = outlr_case_rate_replacement) |>
188
+ case_rate = outlr_case_rate_replacement
189
+ ) |>
185
190
select(geo_value, time_value, case_rate, death_rate)
186
191
cases_deaths
187
192
```
@@ -196,8 +201,8 @@ of the states, noting the actual forecast date:
196
201
forecast_date_label <-
197
202
tibble(
198
203
geo_value = rep(plot_locations, 2),
199
- source = c(rep("case_rate",4), rep("death_rate", 4)),
200
- dates = rep(forecast_date - 7* 2, 2 * length(plot_locations)),
204
+ source = c(rep("case_rate", 4), rep("death_rate", 4)),
205
+ dates = rep(forecast_date - 7 * 2, 2 * length(plot_locations)),
201
206
heights = c(rep(150, 4), rep(1.0, 4))
202
207
)
203
208
processed_data_plot <-
@@ -209,7 +214,8 @@ processed_data_plot <-
209
214
facet_grid(source ~ geo_value, scale = "free") +
210
215
geom_vline(aes(xintercept = forecast_date)) +
211
216
geom_text(
212
- data = forecast_date_label, aes(x=dates, label = "forecast\ndate", y = heights), size = 3, hjust = "right") +
217
+ data = forecast_date_label, aes(x = dates, label = "forecast\ndate", y = heights), size = 3, hjust = "right"
218
+ ) +
213
219
scale_x_date(date_breaks = "3 months", date_labels = "%Y %b") +
214
220
theme(axis.text.x = element_text(angle = 90, hjust = 1))
215
221
```
@@ -260,7 +266,8 @@ narrow_data_plot <-
260
266
facet_grid(source ~ geo_value, scale = "free") +
261
267
geom_vline(aes(xintercept = forecast_date)) +
262
268
geom_text(
263
- data = forecast_date_label, aes(x=dates, label = "forecast\ndate", y = heights), size = 3, hjust = "right") +
269
+ data = forecast_date_label, aes(x = dates, label = "forecast\ndate", y = heights), size = 3, hjust = "right"
270
+ ) +
264
271
scale_x_date(date_breaks = "3 months", date_labels = "%Y %b") +
265
272
theme(axis.text.x = element_text(angle = 90, hjust = 1))
266
273
```
@@ -278,7 +285,8 @@ forecast_plot <-
278
285
epipredict:::plot_bands(
279
286
restricted_predictions,
280
287
levels = 0.9,
281
- fill = primary) +
288
+ fill = primary
289
+ ) +
282
290
geom_point(data = restricted_predictions, aes(y = .data$value), color = secondary)
283
291
```
284
292
</details >
0 commit comments