Add Aggregated Numerator and Denominator Columns Based on Selected Variables
augment_withProportion_modif.RdComputes and appends row-wise total denominators and numerators from specified variables. Optionally estimates missing numerators using available percentage values.
Usage
augment_withProportion_modif(
df,
varname,
denominator_variables,
numerator_variables,
percentage_variables = NULL
)Arguments
- df
A `data.frame` or tibble containing the dataset.
- varname
A string used as prefix to name the new columns (e.g., `HBI.num`, `HBI.den`).
- denominator_variables
Character vector specifying column(s) to sum for the denominator.
- numerator_variables
Character vector specifying column(s) to sum for the numerator.
- percentage_variables
Optional character vector of percentage column(s). When provided, missing numerator values are estimated using:
numerator = denominator * percentage / 100.