Skip to content

Commit e7e767c

Browse files
Add more exampled data
1 parent e911b86 commit e7e767c

10 files changed

Lines changed: 228 additions & 5 deletions

File tree

R/example_data.R

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,74 @@
4343
#'
4444
#' @source Prepared by the VIMC secretariat.
4545
"eg_burden_template"
46+
47+
#' Example of scenario coverage data
48+
#'
49+
#' @format ## `eg_coverage`
50+
#' A data frame with 11 rows and 19 columns.
51+
#' \describe{
52+
#' \item{scenario_type}{Scenario type name.}
53+
#' \item{scenario_type_description}{Scenario type description string.}
54+
#' \item{scenario}{Scenario name string.}
55+
#' \item{scenario_description}{Scenario description string.}
56+
#' \item{coverage_set}{Coverage set string.}
57+
#' \item{gavi_support_level}{String for whether GAVI supported the scenario.}
58+
#' \item{source_from}{String identifier for the source.}
59+
#' \item{disease}{Infection identifier.}
60+
#' \item{vaccine}{Vaccine identifier.}
61+
#' \item{activity_type}{Vaccination activity identifier.}
62+
#' \item{year}{Year}
63+
#' \item{country}{Country name in short format; this is a placeholder name.}
64+
#' \item{age_from}{Age limit lower limit.}
65+
#' \item{age_to}{Age limit upper limit.}
66+
#' \item{age_range_verbatim}{Description of age range.}
67+
#' \item{target}{Target for vaccination.}
68+
#' \item{coverage}{Proportional coverage.}
69+
#' \item{gender}{Sex to which data applies, may be "Male", "Female", or
70+
#' "Both".}
71+
#' \item{proportion_risk}{Proportional risk value.}
72+
#' }
73+
#'
74+
#' @keywords data
75+
#'
76+
#' @source Prepared by the VIMC secretariat.
77+
"eg_coverage"
78+
79+
#' Example of FVP estimate data
80+
#'
81+
#' Example data of fully-vaccinated persons (FVPs).
82+
#'
83+
#' @format ## `eg_fvps`
84+
#' A data frame with 11 rows and 24 columns:
85+
#' \describe{
86+
#' \item{scenario_type}{Scenario type name.}
87+
#' \item{scenario_type_description}{Scenario type description string.}
88+
#' \item{scenario}{Scenario name string.}
89+
#' \item{scenario_description}{Scenario description string.}
90+
#' \item{coverage_set}{Coverage set string.}
91+
#' \item{gavi_support_level}{String for whether GAVI supported the scenario.}
92+
#' \item{source_from}{String identifier for the source.}
93+
#' \item{disease}{Infection identifier.}
94+
#' \item{vaccine}{Vaccine identifier.}
95+
#' \item{activity_type}{Vaccination activity identifier.}
96+
#' \item{year}{Year}
97+
#' \item{country}{Country name in short format; this is a placeholder name.}
98+
#' \item{age_from}{Age limit lower limit.}
99+
#' \item{age_to}{Age limit upper limit.}
100+
#' \item{age_range_verbatim}{Description of age range.}
101+
#' \item{target}{Target for vaccination.}
102+
#' \item{coverage}{Proportional coverage.}
103+
#' \item{gender}{Sex to which data applies, may be "Male", "Female", or
104+
#' "Both".}
105+
#' \item{proportion_risk}{Proportional risk value.}
106+
#' \item{job}{Job code as a numeric.}
107+
#' \item{fvps}{Count of FVPs.}
108+
#' \item{fvps_adjusted}{Count of adjusted FVPs.}
109+
#' \item{target_adjusted}{Adjusted vaccination target.}
110+
#' \item{coverage_adjusted}{Ratio of adjusted FVPs to adjusted target.}
111+
#' }
112+
#'
113+
#' @keywords data
114+
#'
115+
#' @source Prepared by the VIMC secretariat.
116+
"eg_fvps"

R/plotting_prep.R

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ prep_plot_coverage_set <- function(coverage) {
215215
"delivery",
216216
"country",
217217
"year",
218-
"coverage"
218+
"coverage",
219+
"disease"
219220
)
220221
coverage_set <- dplyr::select(
221222
coverage_set,
@@ -226,6 +227,21 @@ prep_plot_coverage_set <- function(coverage) {
226227
no_vax
227228
)
228229

230+
# NOTE: edit factor levels for scenario description
231+
# Set "No vaccination" as first factor level
232+
coverage_set <- dplyr::mutate(
233+
coverage_set,
234+
scenario_description = stringr::str_replace(
235+
.data$scenario_description,
236+
"-|_",
237+
" "
238+
),
239+
scenario_description = forcats::fct_relevel(
240+
.data$scenario_description,
241+
"No vaccination"
242+
)
243+
)
244+
229245
coverage_set
230246
}
231247

@@ -266,8 +282,12 @@ prep_plot_fvp <- function(fvp, year_min, year_max) {
266282
) # convert characters to factors and set first level
267283
)
268284

269-
fvp_final$scenario <- gsub(tolower(fvp$disease[1L]), "", fvp_final$scenario)
270-
fvp_final$scenario <- gsub("-", " ", fvp_final$scenario, fixed = TRUE)
285+
# NOTE: renaming fvp_final$scenario to replace - and _ with spaces
286+
fvp_final$scenario <- stringr::str_replace(
287+
fvp_final$scenario,
288+
"_|-",
289+
" "
290+
)
271291

272292
# determine scenario order in terms of total adjusted FVPs per scenario
273293
scenario_order <- names(sort(
@@ -282,8 +302,9 @@ prep_plot_fvp <- function(fvp, year_min, year_max) {
282302
fvp_final$scenario <- forcats::fct_relevel(fvp_final$scenario, scenario_order)
283303

284304
fvp_agg <- dplyr::summarise(
305+
fvp_final,
285306
fvp = sum(.data$fvps_adjusted, na.rm = TRUE),
286-
.groups = c("year", "scenario", "disease")
307+
.by = c("year", "scenario", "disease")
287308
)
288309

289310
fvp_agg

data-raw/eg_coverage.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## code to prepare `eg_coverage` dataset goes here
2+
3+
eg_coverage <- readr::read_csv(
4+
"inst/extdata/coverage_scenarios.csv",
5+
show_col_types = FALSE
6+
)
7+
8+
usethis::use_data(eg_coverage, overwrite = TRUE)

data-raw/eg_fvps.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## code to prepare `eg_fvps` dataset goes here
2+
3+
eg_fvps <- readr::read_csv(
4+
"inst/extdata/coverage_scenarios.csv",
5+
show_col_types = FALSE
6+
)
7+
8+
# add cols to make eg_FVPs data
9+
eg_fvps$target <- seq(1.5e6, 1.6e6, length.out = nrow(eg_fvps))
10+
eg_fvps$job <- 1
11+
eg_fvps$fvps <- seq(9e5, 1.5e6, length.out = nrow(eg_fvps))
12+
eg_fvps$fvps_adjusted <- eg_fvps$fvps # assumed same as FVPs
13+
eg_fvps$target_adjusted <- eg_fvps$target # assumed same as target
14+
eg_fvps$coverage_adjusted <- eg_fvps$fvps_adjusted / eg_fvps$target_adjusted
15+
16+
usethis::use_data(eg_fvps, overwrite = TRUE)

data/eg_coverage.rda

842 Bytes
Binary file not shown.

data/eg_fvps.rda

1.1 KB
Binary file not shown.

inst/WORDLIST

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ BMC
22
Codecov
33
DALYs
44
Echeverria
5+
FVP
56
FVPs
7+
GAVI
68
GHA
79
Hallett
810
Jaspreet
@@ -18,8 +20,8 @@ WIP
1820
WPP
1921
YLLs
2022
autogenerated
23+
facetted
2124
ggplot
22-
pkgdown
2325
tibble
2426
tibbles
2527
timeseries
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"scenario_type","scenario_type_description","scenario","scenario_description","coverage_set","gavi_support_level","source_from","disease","vaccine","activity_type","year","country","age_from","age_to","age_range_verbatim","target","coverage","gender","proportion_risk"
2+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2030,"RFP",0,0,"default routine age","NA",0.8,"Both",1
3+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2031,"RFP",0,0,"default routine age","NA",0.8,"Both",1
4+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2032,"RFP",0,0,"default routine age","NA",0.8,"Both",1
5+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2033,"RFP",0,0,"default routine age","NA",0.8,"Both",1
6+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2034,"RFP",0,0,"default routine age","NA",0.8,"Both",1
7+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2035,"RFP",0,0,"default routine age","NA",0.8,"Both",1
8+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2036,"RFP",0,0,"default routine age","NA",0.8,"Both",1
9+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2037,"RFP",0,0,"default routine age","NA",0.8,"Both",1
10+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2038,"RFP",0,0,"default routine age","NA",0.8,"Both",1
11+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2039,"RFP",0,0,"default routine age","NA",0.8,"Both",1
12+
"disease_rout","Routine Only","disease_rout","disease_rout","disease : disease , routine ,with: disease_rout","with","scenario_source","disease","disease","routine",2040,"RFP",0,0,"default routine age","NA",0.8,"Both",1

man/eg_coverage.Rd

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/eg_fvps.Rd

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)