Replace binary columns with NA for a subset of the data
replace_na_subset.Rd
This function replaces binary columns (which correspond to choices) with NA
for a specified subset of the data.
It is typically used when expanding top priority columns into child binary columns, ensuring that child columns for
choices that do not apply to a subset are set to NA
.
Arguments
- data
A data.table or data.frame: The data to be processed.
- subset_col
A character vector: The name of the column that defines the subset.
- subset_value
A character vector: The value in
subset_col
for which binary columns will be replaced withNA
.- sep
A character vector: The separator used in the child binary column names (default is ".").
- col_parent
A character vector: The name of the parent column (usually the question) that defines child binary columns.
- choice_vals
A character vector: The values corresponding to the child binary columns that should be replaced with
NA
.