Skip to contents

Wrapper around addindicators::review_variables specific to review analysis.

Usage

review_analysis(
  results_table,
  stat_columns_to_review = "stat.x",
  stat_columns_to_compare_with = "stat.y",
  analysis_key_column = "analysis_key",
  prefix = "review"
)

Arguments

results_table

Results table with an analysis key

stat_columns_to_review

Vectors of columns to review (should be paired with columns_to_compare_with). Default is "stat.x".

stat_columns_to_compare_with

Vectors of columns to compare with (should be paired with columns_to_review). Default is "stat.y"

analysis_key_column

character vector with the name of the analysis key column. Default is "analysis key"

prefix

Prefix to be used for the review and comment column. Default is "review".

Value

A list with two objects:

  • the result table the review and comment columns

  • the review table

Examples

analysis_key_column <-  c("mean @/@ income %/% NA @/@ NA %/% NA",
                          "prop_select_one @/@ water_source %/% tap_water @/@ district %/% district_a",
                          "prop_select_one @/@ water_source %/% tap_water @/@ district %/% district_a -/- population %/% displaced",
                          "prop_select_multiple @/@ source_information %/% relatives @/@ NA %/% NA",
                          "ratio @/@ food_expenses %/% NA -/- total_expenses %/% NA @/@ NA %/% NA",
                          "prop_select_one @/@ water_source %/% tap_water @/@ population %/% displaced",
                          "ratio @/@ food_expenses %/% NA -/- total_expenses %/% NA @/@ district %/% district_a",
                          "prop_select_one @/@ water_source %/% tap_water @/@ population %/% returnees")
test_analysis_results <- data.frame(
  test = c(
    "test equality",
    "test difference",
    "test Missing in y",
    "test Missing in x",
    "test equality rounding in x",
    "test equality rounding in y",
    "test difference rounding in x",
    "test difference rounding in y"
  ),
  stat_col.x = c(0, 1, 2, NA, 0.00019, 0.0002, 0.00035, 0.0003),
  upp_col.x = c(0, 1, 2, NA, 0.00019, 0.0002, 0.00035, 0.0003),
  stat_col.y = c(0, 2, NA, 3, 0.0002, 0.00019, 0.0003, 0.00035),
  upp_col.y = c(0, 2, NA, 3, 0.0002, 0.00019, 0.0003, 0.00035),
  analysis_key = analysis_key_column
)

review_analysis(test_analysis_results,
                stat_columns_to_review = "stat_col.x",
                stat_columns_to_compare_with = "stat_col.y")
#> $results_table
#>                            test stat_col.x upp_col.x stat_col.y upp_col.y
#> 1                 test equality    0.00000   0.00000    0.00000   0.00000
#> 2               test difference    1.00000   1.00000    2.00000   2.00000
#> 3             test Missing in y    2.00000   2.00000         NA        NA
#> 4             test Missing in x         NA        NA    3.00000   3.00000
#> 5   test equality rounding in x    0.00019   0.00019    0.00020   0.00020
#> 6   test equality rounding in y    0.00020   0.00020    0.00019   0.00019
#> 7 test difference rounding in x    0.00035   0.00035    0.00030   0.00030
#> 8 test difference rounding in y    0.00030   0.00030    0.00035   0.00035
#>                                                                                              analysis_key
#> 1                                                                    mean @/@ income %/% NA @/@ NA %/% NA
#> 2                              prop_select_one @/@ water_source %/% tap_water @/@ district %/% district_a
#> 3 prop_select_one @/@ water_source %/% tap_water @/@ district %/% district_a -/- population %/% displaced
#> 4                                 prop_select_multiple @/@ source_information %/% relatives @/@ NA %/% NA
#> 5                                  ratio @/@ food_expenses %/% NA -/- total_expenses %/% NA @/@ NA %/% NA
#> 6                             prop_select_one @/@ water_source %/% tap_water @/@ population %/% displaced
#> 7                    ratio @/@ food_expenses %/% NA -/- total_expenses %/% NA @/@ district %/% district_a
#> 8                             prop_select_one @/@ water_source %/% tap_water @/@ population %/% returnees
#>   review_check_stat_col.x review_comment_stat_col.x
#> 1                    TRUE              Same results
#> 2                   FALSE         Different results
#> 3                   FALSE     Missing in stat_col.y
#> 4                   FALSE     Missing in stat_col.x
#> 5                    TRUE              Same results
#> 6                    TRUE              Same results
#> 7                   FALSE         Different results
#> 8                   FALSE         Different results
#> 
#> $review_table
#>                                                                                              analysis_key
#> 1                                                                    mean @/@ income %/% NA @/@ NA %/% NA
#> 2                              prop_select_one @/@ water_source %/% tap_water @/@ district %/% district_a
#> 3 prop_select_one @/@ water_source %/% tap_water @/@ district %/% district_a -/- population %/% displaced
#> 4                                 prop_select_multiple @/@ source_information %/% relatives @/@ NA %/% NA
#> 5                                  ratio @/@ food_expenses %/% NA -/- total_expenses %/% NA @/@ NA %/% NA
#> 6                             prop_select_one @/@ water_source %/% tap_water @/@ population %/% displaced
#> 7                    ratio @/@ food_expenses %/% NA -/- total_expenses %/% NA @/@ district %/% district_a
#> 8                             prop_select_one @/@ water_source %/% tap_water @/@ population %/% returnees
#>         stat review_check        review_comment        analysis_type
#> 1 stat_col.x         TRUE          Same results                 mean
#> 2 stat_col.x        FALSE     Different results      prop_select_one
#> 3 stat_col.x        FALSE Missing in stat_col.y      prop_select_one
#> 4 stat_col.x        FALSE Missing in stat_col.x prop_select_multiple
#> 5 stat_col.x         TRUE          Same results                ratio
#> 6 stat_col.x         TRUE          Same results      prop_select_one
#> 7 stat_col.x        FALSE     Different results                ratio
#> 8 stat_col.x        FALSE     Different results      prop_select_one
#>                       analysis_var               group_var
#> 1                           income                      NA
#> 2                     water_source                district
#> 3                     water_source district %/% population
#> 4               source_information                      NA
#> 5 food_expenses %/% total_expenses                      NA
#> 6                     water_source              population
#> 7 food_expenses %/% total_expenses                district
#> 8                     water_source              population
#>