
Process raw Independent Monitoring (IM) data into missed-children rates
Source:R/clean_lqas_im.R
process_im.RdCleans the raw POLIS Im table with the same recipe as clean_afp() /
clean_sia() – standardise names via the crosswalk, clean strings, parse and
sanitise dates, fix admin names and (when a shape is supplied) reconcile
admin GUIDs, then dedup by id – and computes the missed-children fraction
per district-year separately for in-house and out-of-house monitoring.
For each setting missed = 1 - sum(marked)/sum(checked), falling back to
mean(result) when no children were checked, with a Valid/Invalid status
flag (Invalid when the result is missing or negative).
Usage
process_im(
im,
cfg = polis_active_config(),
shape = NULL,
verbose = TRUE,
summary = TRUE
)Arguments
- im
Raw IM table (data.frame/tibble).
- cfg
A
polis_config()object (defaultpolis_config()); itscrosswalkmaps the raw column names to canonical snake_case.- shape
Optional district shape (an
sfpolygon layer or a long ADM2 attribute table) for admin GUID reconciliation viareconcile_admin_guids()(keyed onyear). DefaultNULL.- verbose
Emit cli progress + the one-line roll-up result (default
TRUE).- summary
Emit the full cli summary panel (per-setting missed-children). Default
TRUE;run_pipeline()passesFALSEto keep the pipeline terse.
Value
A list with district (per-district-year, carrying both
missed_frac_inhouse / im_status_inhouse and missed_frac_outhouse /
im_status_outhouse plus their checked/marked totals) and meta.
Examples
im <- data.frame(
Id = 1L, Admin0 = "NIGERIA", Admin1 = "KANO", Admin2 = "NASSARAWA",
Admin2GUID = "{A2}", ActivityPlannedDateFromYear = 2024L,
HouseholdsNumberChildrenChecked = 20L,
HouseholdsNumberChildrenMarked = 18L, HouseholdsResult = NA_real_,
OutOfHouseNumberChildrenChecked = 10L,
OutOfHouseNumberChildrenMarked = 8L, OutOfHouseResult = NA_real_
)
process_im(im, verbose = FALSE)$district
#> # A tibble: 1 × 13
#> year adm2_guid adm0 adm1 adm2 n_checked_inhouse n_marked_inhouse
#> <int> <chr> <chr> <chr> <chr> <dbl> <dbl>
#> 1 2024 {A2} NIGERIA KANO NASSARAWA 20 18
#> # ℹ 6 more variables: missed_frac_inhouse <dbl>, n_checked_outhouse <dbl>,
#> # n_marked_outhouse <dbl>, missed_frac_outhouse <dbl>,
#> # im_status_inhouse <chr>, im_status_outhouse <chr>