
Regional Surveillance Indicators by Year (Multi-country aggregate)
generate_surv_reg_tab.RdComputes region-level time series of surveillance indicators by aggregating across all countries present in your inputs (or implicitly after the joins). The function:
builds district-level indicators, restricts to districts with U15 ≥ 100,000,
derives the % population in adequate districts (NPAFP rate ≥ 2 and stool adequacy ≥ 80%), and counts of adequate vs. total ≥100k districts,
aggregates country-level indicators to the region using simple means for rates and sums for AFP cases, and
returns either a tidy tibble or a formatted
flextable.
Usage
generate_surv_reg_tab(
ctry_data,
ctry.extract,
dist.extract,
cstool,
dstool,
afp.cases,
start_year = NULL,
end_year = NULL,
output = c("flextable", "tibble")
)Arguments
- ctry_data
A list-like object that contains at least
dist.pop, a data frame with district metadata. Must include columns:ctry(country code/name),adm2guid(district id), and preferablyyearand a U15 population column (e.g.,u15pop).
- ctry.extract
Country-level dataset (one row per country-year). Should contain
yearand eitheradm0guid(to join withcstool) orctry. It should includenpafp_rateandper.stool.ad, or columns that can be unambiguously renamed to these.- dist.extract
District-level dataset (one row per district-year) with at minimum
adm2guidandyear. If it already containsu15pop,npafp_rate,per.stool.ad, those are used; otherwise they may be pulled in via joins.- cstool
Country-level surveillance stool adequacy dataset with
yearand eitheradm0guidorctry, containingnpafp_rateandper.stool.ad(or columns that can be renamed to these).- dstool
District-level surveillance stool adequacy dataset with
adm2guid,year, and indicator columns such asnpafp_rate,per.stool.ad.- afp.cases
Either:
country-year AFP case data with columns
ctry,year, and a cases column (e.g.,afp.cases,afp.case,cases) orregion/overall year totals with
yearand a cases column. The function will rename the first matching cases column toafp.cases.
- start_year, end_year
Optional numeric bounds to filter the analysis years, inclusive.
- output
One of
"flextable"(default) or"tibble". When"tibble", returns a data frame with columns:year,afp.cases,npafp_rate,per.stool.ad,prop.dist.adeq,prop.
Details
U15 population column detection: the function tries to ensure a column
named u15pop exists in the joined district data by:
coalescing
u15pop.x/u15pop.yafter joins,renaming common aliases (e.g.,
u15_pop,U15Pop,under15_pop), orimporting from
ctry_data$dist.popbyadm2guidandyear.
Adequacy rule (district level):
Adequate if
npafp_rate >= 2andper.stool.ad >= 80.The % population in adequate ≥100k districts is: \(100 * (sum(U15 in adequate ≥100k districts) / sum(U15 in all ≥100k districts))\).
*Aggregation*:
AFP cases: summed across countries per year.
npafp_rateandper.stool.ad: simple means across countries per year (switch to a weighted mean if needed).
The output flextable renders year as plain text (no thousands separator).