1111# '
1212# ' @param path_burden A directory with burden estimate data.
1313# '
14- # ' @return Nothing; called primarily for its side-effets .
14+ # ' @return Nothing; called primarily for its side-effects .
1515# ' If the file `path_burden/file_dictionary.csv` does not exist, a file
1616# ' dictionary CSV file is written to the same location.
1717# ' Prints a message to screen informing the user whether any action has been
1818# ' taken.
1919# '
2020# ' @keywords diagnostics
2121# '
22- # ' @examples
23- # '
2422# ' @export
2523validate_file_dict_template <- function (
2624 disease ,
2725 path_burden = " incoming_burden_estimates"
2826) {
29- # TODO: check conditions on arg disease - what is the original source `pars` ?
27+ # NOTE: maybe need to check allowed options for disease ?
3028
29+ checkmate :: assert_string(disease )
3130 checkmate :: assert_directory_exists(path_burden )
3231 template <- file.path(path_burden , " file_dictionary.csv" )
3332
@@ -64,8 +63,6 @@ validate_file_dict_template <- function(
6463 )
6564 }
6665 } else {
67- # TODO: explain why this branch of the decision tree triggers in fn docs
68-
6966 # NOTE: see expected dir structure in `tests/testthat/testdata/`
7067 scenario_dir <- file.path(path_burden , " model_inputs" )
7168 checkmate :: assert_directory_exists(scenario_dir )
@@ -125,8 +122,6 @@ validate_file_dict_template <- function(
125122# ' @return A `<tibble>` of the scenario file dictionary in `path_burden` if all
126123# ' checks pass. Otherwise, exits with informative errors on failed checks.
127124# '
128- # ' @examples
129- # '
130125# ' @keywords diagnostics
131126# '
132127# ' @export
@@ -145,7 +140,7 @@ validate_complete_incoming_files <- function(
145140 show_col_types = FALSE
146141 )
147142
148- col_filenames <- " file" # TODO: remove/explain magic colnm
143+ col_filenames <- " file"
149144 scenario_filenames <- df_dict [[col_filenames ]]
150145 df_dict <- dplyr :: select(df_dict , - {{ col_filenames }})
151146
@@ -212,11 +207,9 @@ validate_complete_incoming_files <- function(
212207# ' @param template A `<data.frame>` of the burden template as provided to
213208# ' modelling groups by VIMC.
214209# '
215- # ' @return A named list of checks carried out on `burden_set` to comapre it
210+ # ' @return A named list of checks carried out on `burden_set` to compare it
216211# ' against `template`, with information on missing and extra data.
217212# '
218- # ' @examples
219- # '
220213# ' @keywords diagnostics
221214# '
222215# ' @export
@@ -235,7 +228,6 @@ validate_template_alignment <- function(burden_set, template) {
235228 length(extra_cols_in_burden ) ==
236229 0L
237230
238- # TODO: make magic strings constants
239231 key_cols <- c(" disease" , " country" , " year" , " age" )
240232 template_grid <- dplyr :: distinct(
241233 template ,
@@ -250,8 +242,6 @@ validate_template_alignment <- function(burden_set, template) {
250242 })
251243 )
252244
253- # TODO: if these are data.frames, this might not be the best way to check
254- # for differences
255245 missing_grid_in_burden <- dplyr :: setdiff(template_grid , burden_grid )
256246 extra_grid_in_burden <- dplyr :: setdiff(burden_grid , template_grid )
257247 burden_grid_matches_template <- all(
@@ -274,15 +264,19 @@ validate_template_alignment <- function(burden_set, template) {
274264
275265# ' Check incoming burden cohort size against interpolated population
276266# '
277- # ' @description
267+ # ' @description Check the modelled disease burden data has similar population
268+ # ' sizes as the provided population data.
278269# '
279- # ' @param burden_set
270+ # ' @inheritParams validate_template_alignment
280271# '
281- # ' @param wpp
272+ # ' @param wpp Population estimates for the country in `burden_set`, provided by
273+ # ' VIMC.
282274# '
283- # ' @param gender
275+ # ' @param gender The assigned sex for which demography is to be checked. Options
276+ # ' are `"Both"` (default), `"Male"`, or `"Female"`.
284277# '
285- # ' @return
278+ # ' @return A `<tibble>` giving the alignment, i.e., percentage difference of
279+ # ' modelled population size from the WPP-derived population estimates.
286280# '
287281# ' @keywords diagnostics
288282# '
@@ -507,6 +501,7 @@ impact_check <- function(burden, scenario_order) {
507501 scenario_order <- dplyr :: select(scenario_order , {{ scenario_cols }})
508502
509503 d <- dplyr :: summarise(
504+ burden ,
510505 millions = sum(.data $ value ) / 1e6 ,
511506 .by = c(" scenario" , " burden_outcome" ),
512507 .groups = " drop" # probably unnecessary as grouping is temporary
0 commit comments