@@ -60,6 +60,7 @@ API](https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html).
60
60
library(epidatr)
61
61
library(epiprocess)
62
62
library(dplyr)
63
+ library(tidyr)
63
64
library(withr)
64
65
65
66
cases <- pub_covidcast(
@@ -279,30 +280,31 @@ ggplot(x, aes(x = time_value, y = value)) +
279
280
labs(x = "Date", y = "SARS cases in Canada", fill = "Type")
280
281
```
281
282
282
- Data on new cases of Ebola in Sierra Leone in 2014, from the same package:
283
+ Get confirmed cases of Ebola in Sierra Leone from 2014 to 2015 by province and
284
+ date of onset, prepared from line list data from the same package:
283
285
284
- ``` {r, message = FALSE, fig.width = 9, fig.height = 6}
286
+ ``` {r, fig.width = 9, fig.height = 6}
285
287
x <- outbreaks::ebola_sierraleone_2014 %>%
286
- mutate(
287
- cases = ifelse(status == "confirmed", 1, 0),
288
- province = case_when(
289
- district %in% c("Kailahun", "Kenema", "Kono") ~ "Eastern",
290
- district %in% c(
291
- "Bombali", "Kambia", "Koinadugu",
292
- "Port Loko", "Tonkolili"
293
- ) ~ "Northern",
294
- district %in% c("Bo", "Bonthe", "Moyamba", "Pujehun") ~ "Sourthern",
295
- district %in% c("Western Rural", "Western Urban") ~ "Western"
296
- )
297
- ) %>%
298
- select(
299
- geo_value = province,
300
- time_value = date_of_onset,
301
- cases
288
+ select(district, date_of_onset, status) %>%
289
+ mutate(province = case_when(
290
+ district %in% c("Kailahun", "Kenema", "Kono") ~
291
+ "Eastern",
292
+ district %in% c(
293
+ "Bombali", "Kambia", "Koinadugu", "Port Loko",
294
+ "Tonkolili"
295
+ ) ~
296
+ "Northern",
297
+ district %in% c("Bo", "Bonthe", "Moyamba", "Pujehun") ~
298
+ "Sourthern",
299
+ district %in% c("Western Rural", "Western Urban") ~
300
+ "Western"
301
+ )) %>%
302
+ group_by(geo_value = province, time_value = date_of_onset) %>%
303
+ summarise(cases = sum(status == "confirmed"), .groups = "drop") %>%
304
+ complete(geo_value,
305
+ time_value = full_seq(time_value, period = 1),
306
+ fill = list(cases = 0)
302
307
) %>%
303
- filter(cases == 1) %>%
304
- group_by(geo_value, time_value) %>%
305
- summarise(cases = sum(cases)) %>%
306
308
as_epi_df(geo_type = "province", as_of = as.Date("2024-03-20"))
307
309
308
310
ggplot(x, aes(x = time_value, y = cases)) +
0 commit comments