Skip to content

Commit ca1bcb1

Browse files
authored
Merge pull request #43 from cmu-delphi/epiprocess-vignette
New example in vignette
2 parents cf3100c + a8ff3b5 commit ca1bcb1

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ Imports:
4747
Suggests:
4848
delphi.epidata
4949
Remotes:
50-
github:cmu-delphi/delphi-epidata-r
50+
github::cmu-delphi/delphi-epidata-r

vignettes/epiprocess.Rmd

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ title: Get started with `epiprocess`
33
output: rmarkdown::html_vignette
44
vignette: >
55
%\VignetteIndexEntry{Get started with epiprocess}
6-
%\VignetteEngine{knitr::rmarkdown}
76
%\VignetteEncoding{UTF-8}
7+
%\VignetteEngine{knitr::rmarkdown}
8+
editor_options:
9+
chunk_output_type: console
810
---
911

1012
This package introduces a common data structure for epidemiological data sets
@@ -165,4 +167,32 @@ ggplot(x, aes(x = time_value, y = value)) +
165167
labs(x = "Date", y = "SARS cases in Canada", fill = "Type")
166168
```
167169

168-
*todo: include another example here*
170+
Also from the [outbreaks](https://github.com/reconverse/outbreaks) package, we use the function `as_epi_df` on confirmed cases of ebola in Sierra Leone in 2014.
171+
172+
```{r,message=FALSE}
173+
x = outbreaks::ebola_sierraleone_2014 %>%
174+
mutate(
175+
cases=ifelse(status=='confirmed',1,0),
176+
province = case_when(
177+
district %in% c('Kailahun','Kenema','Kono') ~ "Eastern",
178+
district %in% c('Bombali','Kambia','Koinadugu',
179+
'Port Loko','Tonkolili') ~ 'Northern',
180+
district %in% c('Bo','Bonthe','Moyamba','Pujehun') ~ 'Sourthern',
181+
district %in% c('Western Rural','Western Urban') ~ 'Western')) %>%
182+
select(geo_value=province,
183+
time_value = date_of_onset,
184+
cases) %>% filter(cases==1) %>%
185+
group_by(geo_value,time_value) %>%
186+
summarise(cases=sum(cases)) %>%
187+
as_epi_df(geo_type='province')
188+
189+
ggplot(x, aes(x = time_value, y = cases,fill=geo_value)) +
190+
geom_col() + facet_grid(geo_value~.)+
191+
scale_x_date(minor_breaks = "month", date_labels = "%b %y") +
192+
labs(x = "Date", y = "Confirmed cases of ebola")+
193+
guides(fill=guide_legend(title="Province"))
194+
```
195+
196+
197+
198+

0 commit comments

Comments
 (0)