Calculates weighted proportions (as percentages) with 95% confidence intervals for a yes/no variable, optionally stratified by a grouping variable.

svyprop(formula, design, by = NULL, na.rm = TRUE)

Arguments

formula

A formula (e.g., ~variable or using binary variables).

design

A survey design object (from setup_survey_design()).

by

Optional formula for stratification (e.g., ~sex).

na.rm

Logical; if TRUE (default), omit NA values.

Value

A data frame with columns:

  • estimate: estimated proportion (%)

  • lower: 95% CI lower bound (%)

  • upper: 95% CI upper bound (%)

  • se: standard error (%)

  • If by is specified: grouping column(s) prepended