View source: R/define-deprivation.R
| define_deprivation | R Documentation |
Sets a deprivation cutoff for a single indicator. For each
unit of analysis, the result is 0 (not deprived), 1
(deprived), or NA (missing). An additional weighted column
(indicator value × weight) is also computed.
define_deprivation(
.data,
indicator,
cutoff,
mpi_specs = NULL,
collapse_fn = NULL,
set_na_equal_to = 0,
...
)
.data |
A data frame or tibble. |
indicator |
Name of the indicator as defined in the MPI Specs (must
exactly match the |
cutoff |
A logical expression that evaluates to |
mpi_specs |
MPI specifications from |
collapse_fn |
An optional function to collapse roster-level data to
the unit-of-analysis level (e.g. |
set_na_equal_to |
Coerce |
... |
Reserved; passing old dotted names triggers a helpful error. |
A data frame with columns *_unweighted and *_weighted.
define_mpi_specs
specs_file <- system.file(
"extdata",
"global-mpi-specs.csv",
package = "mpindex"
)
specs <- define_mpi_specs(specs_file, uid = "uuid")
define_deprivation(
df_household,
indicator = drinking_water,
cutoff = drinking_water == 2,
mpi_specs = specs
)
define_deprivation(
df_household_roster,
indicator = school_attendance,
cutoff = attending_school == 2,
mpi_specs = specs,
collapse_fn = max
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.