Skip to contents

This function replaces the top 1/2/3 binary columns (which correspond to choices) with NA for a specified subset of the data.

Usage

clean_top_priorities_subset(
  data,
  col_prio = c("hesper_priority_first", "hesper_priority_second",
    "hesper_priority_third"),
  subset_cols_vals = list(pop_group = list(displaced = list(subset_val = c("idp",
    "refugees"), col_val = c("hesper_displaced"))), resp_gender = list(female =
    list(subset_val = c("female"), col_val = c("hesper_clean_women")))),
  sep_val = "."
)

Arguments

data

A data frame or data table

col_prio

A character vector of length 3 with the names of the top 1/2/3 priority columns

subset_cols_vals

A list of list with the names of the columns to subset the data and the values to subset the data This list be a nested list with names of the subset columns as first layer, with as many names as subset dimension to clean for For each subset dimension, another list with as many values than subset groups that needs to be cleaned with then two list elements linking to all values corresponding to the subset in data set followed by the choice value for the parent target columns that needs to be cleaned with NA for the corresponding subset

sep_val

A character scalar as the separator used in the child binary column names

Value

A data frame or data table with the top 1/2/3 priority columns replaced with NA for the specified subset of the data