Computes and appends row-wise total denominators and numerators from specified variables. Optionally estimates missing numerators using available percentage values.

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.

Value

A dataframe identical to `df` but with two additional columns:

<varname>.num

Total numerator, estimated using percentages if necessary.

<varname>.den

Total denominator. Zero values are treated as `NA`.