Skip to content

Commit ec2c4e9

Browse files
committed
add package dependency and namespace to functions
1 parent e5dc91c commit ec2c4e9

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

episodes/vaccine-comparisons.Rmd

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ In this tutorial we will compare different vaccination strategies using models f
4141
library(ggplot2)
4242
library(epidemics)
4343
library(dplyr)
44+
library(purrr)
4445
```
4546

4647
## Key Terms
@@ -432,7 +433,7 @@ This **indirect** effect of vaccination programs is key to successfully controll
432433

433434
To evaluate the impact of vaccination programs, we often consider both the peak size, which indicates healthcare pressure at a single point in time, and the overall epidemic size, which refers to the cumulative number of infections.
434435

435-
We can find the cumulative sum using the R function `cumsum()` and use `purr::map_dfr()` to loop over a list of new infection data frames. We can see the difference in infection numbers is by several orders of magnitude.
436+
We can find the cumulative sum using the R function `cumsum()` and use `purrr::map_dfr()` to loop over a list of new infection data frames. We can see the difference in infection numbers is by several orders of magnitude.
436437

437438
```{r}
438439
# create function that returns the intervention type and cumulative sum for
@@ -449,7 +450,7 @@ interventions <- lst(baseline_infections,
449450
vaccinate_02_infections)
450451
451452
# apply function to each data frame in the list
452-
map_dfr(interventions, find_cumsum)
453+
purrr::map_dfr(interventions, find_cumsum)
453454
```
454455

455456

@@ -720,7 +721,7 @@ interventions_targetted <- lst(baseline_infections,
720721
vaccinate_group_3_infections)
721722
722723
# apply function to each data frame in the list
723-
map_dfr(interventions_targetted, find_cumsum)
724+
purrr::map_dfr(interventions_targetted, find_cumsum)
724725
```
725726

726727
### Age-specific infection-fatality-risk
@@ -741,7 +742,7 @@ vaccinate_group_1_age <- new_infections(output_vaccinate_group_1,
741742
742743
vaccinate_group_1_deaths <-
743744
1:3 %>%
744-
map_dfr(function(x) vaccinate_group_1_age %>%
745+
purrr::map_dfr(function(x) vaccinate_group_1_age %>%
745746
filter(demography_group == names(ifr)[x]) %>%
746747
mutate(deaths = new_infections * ifr[x]))
747748
```
@@ -754,7 +755,7 @@ vaccinate_01_age <- new_infections(output_vaccinate_01,
754755
755756
vaccinate_01_deaths <-
756757
1:3 %>%
757-
map_dfr(function(x) vaccinate_01_age %>%
758+
purrr::map_dfr(function(x) vaccinate_01_age %>%
758759
filter(demography_group == names(ifr)[x]) %>%
759760
mutate(deaths = new_infections * ifr[x]))
760761
@@ -764,7 +765,7 @@ vaccinate_group_2_age <- new_infections(output_vaccinate_group_2,
764765
765766
vaccinate_group_2_deaths <-
766767
1:3 %>%
767-
map_dfr(function(x) vaccinate_group_2_age %>%
768+
purrr::map_dfr(function(x) vaccinate_group_2_age %>%
768769
filter(demography_group == names(ifr)[x]) %>%
769770
mutate(deaths = new_infections * ifr[x]))
770771
@@ -774,7 +775,7 @@ vaccinate_group_3_age <- new_infections(output_vaccinate_group_3,
774775
775776
vaccinate_group_3_deaths <-
776777
1:3 %>%
777-
map_dfr(function(x) vaccinate_group_3_age %>%
778+
purrr::map_dfr(function(x) vaccinate_group_3_age %>%
778779
filter(demography_group == names(ifr)[x]) %>%
779780
mutate(deaths = new_infections * ifr[x]))
780781
@@ -785,7 +786,7 @@ baseline_age <- new_infections(output_baseline,
785786
786787
baseline_deaths <-
787788
1:3 %>%
788-
map_dfr(function(x) baseline_age %>%
789+
purrr::map_dfr(function(x) baseline_age %>%
789790
filter(demography_group == names(ifr)[x]) %>%
790791
mutate(deaths = new_infections * ifr[x]))
791792
```

0 commit comments

Comments
 (0)