Calculate (simple) weights based on the proportion of another variable.

calc_weights(data, weight_var, target, weight_label = "weight")

Arguments

data

Data frame or tibble containing the variable used for computing weights

weight_var

The variable to be used for computing the weight

target

A named vector containing the target weights. Names must mtach labels for weight_var

weight_label

A character vector to specify the variable name of the weight variable. Defaults to 'weight'.