Skip to contents

Calculate N qualtiles of a variables from the CEQ results

Usage

calc_deciles(
  dta,
  dec_var,
  n_dec = 10,
  wt_var = get_wt_nm(),
  dec_var_name = "{.col}_decile",
  dec_min_level = NULL,
  dec_max_level = NULL,
  ...
)

Arguments

dta

data frame with the simulation results.

n_dec

number of quantiles/deciles to create. Default is 10.

wt_var

character name of a single variable that should be used as a weighting variable in calculation. Default is get_wt_nm()$var. If wt_var is not provided or the one provided is not present in `dta`, warning will be prompted.

var

character of a single variable name or an unnamed character vector of variables created with `c(...)`. These variables will be used for creating N quantiles. Default `get_inc_nm()$var` that represents all income concepts.

Value

the same data frame with addition column (s). One column per each `var` used for computing deciles. If we provide `var = "ypf_SA2"` the resulting data frame will contain additional variable `ypf_SA2_decile`. If we specify a list of variables, as many additional variables will be created with extension `_decile` in their name.