Generates a list of ggplot2 plots showing key NCD risk factor prevalence with 95% confidence intervals, stratified by sex and age group.

build_steps_plots(indicators, key_indicators, country_name, survey_year)

Arguments

indicators

A list of indicator results from compute_all_indicators().

key_indicators

A data frame with key indicators (domain, indicator, estimate, lower, upper).

country_name

Country name for plot titles.

survey_year

Survey year for plot titles.

Value

A named list of ggplot2 objects:

  • overview: Horizontal bar chart of key indicators

  • tobacco_by_sex: Sex-stratified tobacco use

  • bp_by_sex: Sex-stratified blood pressure

  • obesity_by_sex: Sex-stratified overweight/obesity

  • glucose_by_sex: Sex-stratified blood glucose

  • bp_by_age: Age-stratified blood pressure with ribbon CI

  • obesity_by_age: Age-stratified overweight/obesity with ribbon CI

  • sex_dashboard: Combined 2x2 dashboard of sex-stratified charts (if >=2 sex plots available) NULL entries are preserved in the list.

Details

All plots use the WHO STEPS colour scheme and professional styling. Error bars represent 95% confidence intervals. Prevalence values are displayed on bars/points with light background text.

Examples

# \donttest{
  test_data <- generate_test_data(n = 500, seed = 42)
#> ✓ Generated test data: 500 rows × 28 columns
  cols <- detect_steps_columns(test_data)
#>   Detecting STEPS columns...
#>   ✓ Age: 'age'
#>   ✓ Sex: 'sex'
#>   ⚠ Could not auto-detect column for: Age range group
#>   ⚠ Could not auto-detect column for: Valid/consent flag
#>   ⚠ Could not auto-detect column for: Urban/rural
#>   ✓ Weight Step 1 (behavioural): 'wt_final'
#>   ⚠ Could not auto-detect column for: Weight Step 2 (physical)
#>   ⚠ Could not auto-detect column for: Weight Step 3 (biochemical)
#>   ✓ Stratum: 'stratum'
#>   ✓ PSU: 'psu'
#>   ✓ Current tobacco use: 't1'
#>   ✓ Daily tobacco use: 't2'
#>   ⚠ Could not auto-detect column for: Age started smoking
#>   ⚠ Could not auto-detect column for: Smoking duration
#>   ⚠ Could not auto-detect column for: Manufactured cigarettes/day
#>   ⚠ Could not auto-detect column for: Manufactured cigarettes/week
#>   ⚠ Could not auto-detect column for: Hand-rolled cigarettes/day
#>   ⚠ Could not auto-detect column for: Pipes/day
#>   ⚠ Could not auto-detect column for: Cigars/day
#>   ⚠ Could not auto-detect column for: Shisha/day
#>   ⚠ Could not auto-detect column for: Quit attempt past 12m
#>   ⚠ Could not auto-detect column for: Advised to quit by HCP
#>   ⚠ Could not auto-detect column for: Past smoking
#>   ⚠ Could not auto-detect column for: Past daily smoking
#>   ⚠ Could not auto-detect column for: Quitting age
#>   ⚠ Could not auto-detect column for: Duration since quitting
#>   ⚠ Could not auto-detect column for: Current smokeless tobacco
#>   ⚠ Could not auto-detect column for: Daily smokeless tobacco
#>   ⚠ Could not auto-detect column for: Snuff mouth/day
#>   ⚠ Could not auto-detect column for: Chewing tobacco/day
#>   ⚠ Could not auto-detect column for: Betel quid/day
#>   ⚠ Could not auto-detect column for: Past smokeless tobacco
#>   ⚠ Could not auto-detect column for: Past daily smokeless
#>   ⚠ Could not auto-detect column for: Second-hand smoke at home
#>   ⚠ Could not auto-detect column for: Second-hand smoke at workplace
#>   ⚠ Could not auto-detect column for: Any tobacco product
#>   → Skipped 'a1' for Ever consumed alcohol (label '' does not match)
#>   ⚠ Could not auto-detect column for: Ever consumed alcohol
#>   ⚠ Could not auto-detect column for: Alcohol past 12 months
#>   → Skipped 'a5' for Current alcohol use (past 30 days) (label '' does not match)
#>   → Skipped 'a1' for Current alcohol use (past 30 days) (label '' does not match)
#>   ⚠ Could not auto-detect column for: Current alcohol use (past 30 days)
#>   ⚠ Could not auto-detect column for: Heavy episodic drinking
#>   ⚠ Could not auto-detect column for: Stopped drinking
#>   ⚠ Could not auto-detect column for: Alcohol frequency (past 12m)
#>   ⚠ Could not auto-detect column for: Drinking occasions (past 30d)
#>   ⚠ Could not auto-detect column for: Drinks per occasion
#>   ⚠ Could not auto-detect column for: Largest drinks on one occasion
#>   ⚠ Could not auto-detect column for: Times with 6+ drinks
#>   ⚠ Could not auto-detect column for: Alcohol 7-day frequency
#>   ⚠ Could not auto-detect column for: Homebrew consumption
#>   ⚠ Could not auto-detect column for: Drinking level category
#>   ✓ Total MET minutes: 'met_total'
#>   ⚠ Could not auto-detect column for: Vigorous work activity
#>   ⚠ Could not auto-detect column for: Moderate work activity
#>   ⚠ Could not auto-detect column for: Walk/bicycle transport
#>   ⚠ Could not auto-detect column for: Vigorous recreational activity
#>   ⚠ Could not auto-detect column for: Moderate recreational activity
#>   ⚠ Could not auto-detect column for: Sedentary behaviour
#>   ✓ Fruit days/week: 'd1'
#>   ✓ Fruit servings/day: 'd2'
#>   ✓ Vegetable days/week: 'd3'
#>   ✓ Vegetable servings/day: 'd4'
#>   ⚠ Could not auto-detect column for: Salt added at table
#>   ⚠ Could not auto-detect column for: Salt added in cooking
#>   ⚠ Could not auto-detect column for: Processed food high in salt
#>   ⚠ Could not auto-detect column for: Perceived salt intake
#>   ⚠ Could not auto-detect column for: Importance of lowering salt
#>   ⚠ Could not auto-detect column for: Knowledge of salt effects
#>   ⚠ Could not auto-detect column for: Limit processed food for salt
#>   ⚠ Could not auto-detect column for: Check salt labels
#>   ⚠ Could not auto-detect column for: Buy low-salt alternatives
#>   ⚠ Could not auto-detect column for: Use spices instead of salt
#>   ⚠ Could not auto-detect column for: Avoid food outside home
#>   ⚠ Could not auto-detect column for: Other salt control action
#>   ⚠ Could not auto-detect column for: Type of cooking oil/fat
#>   ⚠ Could not auto-detect column for: Meals outside home per week
#>   ⚠ Could not auto-detect column for: Vigorous work days/week
#>   ⚠ Could not auto-detect column for: Vigorous work hours
#>   ⚠ Could not auto-detect column for: Vigorous work minutes
#>   ⚠ Could not auto-detect column for: Moderate work days/week
#>   ⚠ Could not auto-detect column for: Moderate work hours
#>   ⚠ Could not auto-detect column for: Moderate work minutes
#>   ⚠ Could not auto-detect column for: Transport days/week
#>   ⚠ Could not auto-detect column for: Transport hours
#>   ⚠ Could not auto-detect column for: Transport minutes
#>   ⚠ Could not auto-detect column for: Vigorous recreation days/week
#>   ⚠ Could not auto-detect column for: Vigorous recreation hours
#>   ⚠ Could not auto-detect column for: Vigorous recreation minutes
#>   ⚠ Could not auto-detect column for: Moderate recreation days/week
#>   ⚠ Could not auto-detect column for: Moderate recreation hours
#>   ⚠ Could not auto-detect column for: Moderate recreation minutes
#>   ⚠ Could not auto-detect column for: Sedentary hours
#>   ⚠ Could not auto-detect column for: Sedentary minutes
#>   ⚠ Could not auto-detect column for: BP ever measured
#>   ⚠ Could not auto-detect column for: Ever diagnosed raised BP
#>   ⚠ Could not auto-detect column for: BP diagnosed past 12m
#>   ⚠ Could not auto-detect column for: Traditional healer for BP
#>   ⚠ Could not auto-detect column for: Herbal remedy for BP
#>   ⚠ Could not auto-detect column for: Blood sugar ever measured
#>   ⚠ Could not auto-detect column for: Ever diagnosed diabetes
#>   ⚠ Could not auto-detect column for: DM diagnosed past 12m
#>   ⚠ Could not auto-detect column for: Currently on insulin
#>   ⚠ Could not auto-detect column for: Traditional healer for DM
#>   ⚠ Could not auto-detect column for: Herbal remedy for DM
#>   ⚠ Could not auto-detect column for: Cholesterol ever measured
#>   ⚠ Could not auto-detect column for: Ever diagnosed raised cholesterol
#>   ⚠ Could not auto-detect column for: Chol diagnosed past 12m
#>   ⚠ Could not auto-detect column for: Traditional healer for chol
#>   ⚠ Could not auto-detect column for: Herbal remedy for chol
#>   ⚠ Could not auto-detect column for: CVD history (heart attack/stroke)
#>   ⚠ Could not auto-detect column for: Currently taking aspirin
#>   ⚠ Could not auto-detect column for: Currently taking statins
#>   ⚠ Could not auto-detect column for: Advised: quit tobacco
#>   ⚠ Could not auto-detect column for: Advised: reduce salt
#>   ⚠ Could not auto-detect column for: Advised: eat fruit/veg
#>   ⚠ Could not auto-detect column for: Advised: reduce fat
#>   ⚠ Could not auto-detect column for: Advised: more PA
#>   ⚠ Could not auto-detect column for: Advised: healthy weight
#>   ⚠ Could not auto-detect column for: Cervical cancer screening
#>   ⚠ Could not auto-detect column for: Education years
#>   ✓ Highest education level: 'c5'
#>   ✓ Ethnicity/Caste: 'c6'
#>   ⚠ Could not auto-detect column for: Marital status
#>   ⚠ Could not auto-detect column for: Employment status
#>   ⚠ Could not auto-detect column for: Household income
#>   ✓ Height (cm): 'm1'
#>   ✓ Weight (kg): 'm2'
#>   ✓ Waist circumference (cm): 'm3'
#>   ⚠ Could not auto-detect column for: Hip circumference (cm)
#>   ✓ SBP reading 1: 'b1'
#>   ✓ SBP reading 2: 'b3'
#>   ✓ SBP reading 3: 'b5'
#>   ✓ DBP reading 1: 'b2'
#>   ✓ DBP reading 2: 'b4'
#>   ✓ DBP reading 3: 'b6'
#>   ✓ BP medications: 'b7'
#>   ⚠ Could not auto-detect column for: Pregnancy status
#>   ⚠ Could not auto-detect column for: Heart rate reading 1
#>   ⚠ Could not auto-detect column for: Heart rate reading 2
#>   ⚠ Could not auto-detect column for: Heart rate reading 3
#>   ⚠ Could not auto-detect column for: Mean heart rate
#>   ✓ Fasting blood glucose: 'b5'
#>   ⚠ Could not auto-detect column for: Random blood glucose
#>   ✓ Fasting status: 'b1'
#>   ✓ Diabetes medications: 'b6'
#>   ✓ Total cholesterol: 'c6'
#>   ⚠ Could not auto-detect column for: HDL cholesterol
#>   ⚠ Could not auto-detect column for: Triglycerides
#>   ✓ Cholesterol medications: 'c10'
#>   → 29/147 columns detected automatically
  clean <- clean_steps_data(test_data, cols)
#>   ⚠ No Step 2 weight found - copying Step 1 weight
#>   ⚠ No Step 3 weight found - copying Step 1 weight
#>     ✓ GPAQ special codes (77/88/99) cleaned, values capped at valid ranges
#>     ✓ GPAQ screening questions used to set non-active domains to 0
#>     ✓ Diet special codes (77/88) cleaned; zero-days → 0 servings
#> ✓ Cleaning complete. Final dataset: 500 rows x 64 columns
  design <- setup_survey_design(clean)
#>   Setting up survey designs (per WHO STEPS Step)...
#>   Design: Stratified cluster sampling with weights
#>   → Unweighted n = 500
#>   → Weighted  N (Step 1) = 753
#>   Survey design created
  all_ind <- compute_all_indicators(design)
#> Computing tobacco indicators...
#>   Computing tobacco indicators...
#> Computing alcohol indicators...
#>   Computing alcohol indicators...
#> Computing diet & physical activity indicators...
#>   Computing diet & physical activity indicators...
#> Computing anthropometry indicators...
#>   Computing anthropometry indicators...
#> Computing blood pressure indicators...
#>   Computing blood pressure indicators...
#> Computing biochemical indicators...
#>   Computing biochemical indicators...
#> ✓ Computed 7 key indicators across all domains.
  plots <- build_steps_plots(all_ind$results, all_ind$key_indicators, "Test", 2023)
  names(plots)
#> [1] "overview"       "tobacco_by_sex" "bp_by_sex"      "obesity_by_sex"
#> [5] "bp_by_age"      "obesity_by_age" "forest"         "radar"         
#> [9] "sex_dashboard" 
# }