Skip to contents

Produces a publication-ready summary statistics table for numeric variables in IHS data. Supports grouping by a factor variable and optional survey weights.

Usage

ihs_report(data, vars = NULL, by = NULL, weights = NULL)

Arguments

data

A data.frame.

vars

Character vector of column names to summarise. If NULL (default), all numeric columns are included.

by

Optional character string of a grouping variable (e.g., "region", "urban").

weights

Optional character string of a column containing survey weights for weighted means and SDs.

Value

A data.frame of summary statistics with columns: variable, n, mean, sd, median, min, max, pct_missing. If by is specified, an additional grouping column is included.

Examples

if (FALSE) { # \dontrun{
  # Basic summary
  ihs_report(harmonised_data, vars = c("rexp_cat01", "hhsize"))

  # Grouped by region
  ihs_report(harmonised_data, vars = "rexp_cat01", by = "region")

  # Weighted summary
  ihs_report(harmonised_data, vars = "rexp_cat01", weights = "hh_wgt")
} # }