Skip to content

Commit d89c14c

Browse files
authored
Merge pull request #260 from cmu-delphi/lcb/clarify-ebola-example-code
Avoid `filter(cases==1)`, better describe & `complete` Ebola example
2 parents 009ac43 + 9417d33 commit d89c14c

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: epiprocess
33
Title: Tools for basic signal processing in epidemiology
4-
Version: 0.7.8
4+
Version: 0.7.9
55
Authors@R: c(
66
person("Jacob", "Bien", role = "ctb"),
77
person("Logan", "Brooks", email = "[email protected]", role = c("aut", "cre")),

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.x.y will indicat
2929
argument checking (#413).
3030
- Fix logic to auto-assign `epi_df` `time_type` to `week` (#416) and `year`
3131
(#441).
32+
- Clarified "Get started" example of getting Ebola line list data into `epi_df`
33+
format.
3234

33-
## Breaking changes
35+
# epiprocess 0.7.0
36+
37+
## Breaking changes:
3438

3539
- Switched `epi_df`'s `other_keys` default from `NULL` to `character(0)`; PR #390
3640
- Refactored `epi_archive` to use S3 instead of R6 for its object model. The

vignettes/epiprocess.Rmd

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ API](https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html).
6060
library(epidatr)
6161
library(epiprocess)
6262
library(dplyr)
63+
library(tidyr)
6364
library(withr)
6465
6566
cases <- pub_covidcast(
@@ -279,30 +280,31 @@ ggplot(x, aes(x = time_value, y = value)) +
279280
labs(x = "Date", y = "SARS cases in Canada", fill = "Type")
280281
```
281282

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:
283285

284-
```{r, message = FALSE, fig.width = 9, fig.height = 6}
286+
```{r, fig.width = 9, fig.height = 6}
285287
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)
302307
) %>%
303-
filter(cases == 1) %>%
304-
group_by(geo_value, time_value) %>%
305-
summarise(cases = sum(cases)) %>%
306308
as_epi_df(geo_type = "province", as_of = as.Date("2024-03-20"))
307309
308310
ggplot(x, aes(x = time_value, y = cases)) +

0 commit comments

Comments
 (0)