Attach cleaning overview to the survey data.
Source:R/step_cleaning_overview.R
step_cleaning_overview.RdAttach cleaning overview to the survey data.
Usage
step_cleaning_overview(
x,
.cols_scenarios = starts_with("cs_"),
.cols_group = NULL,
.cols_include = NULL,
.cols_penalty_scores = starts_with("ps_"),
snapshot_data = FALSE
)Arguments
- x
A
srv_tblobject containing survey data.- .cols_scenarios
A selection of logical/numeric columns that represent different cleaning scenarios.
TRUE/1value means we want to drop that response andFALSE/0value means we want to keep it.
- .cols_group
A selection of columns to group the cleaning overview by. Usually a set of demographic factor variables. Function will create a separate summary for each of the levels of these variables.
- .cols_include
A selection of columns to include in the
All flagsoutput.- .cols_penalty_scores
A selection of numeric columns that represent penalty scores.
- snapshot_data
Logical. If
TRUE, a snapshot of the data is taken. IfFALSE, snapshot without data is taken. IfNULL, no snapshot is taken.
Examples
if (FALSE) { # \dontrun{
data("srv_example", package = "g6tr.survey")
x <- srv_example |>
mutate(
# Discrete penalty score
ps_discrete = case_when(
response_duration < 300 ~ 20,
response_duration < 400 ~ 10,
response_duration < 500 ~ 5,
response_duration < 600 ~ 2,
response_duration < 900 ~ 1,
TRUE ~ 0),
# Continuous penalty score
ps_continuous = pmax(0, 100 - (response_duration - 100)/5)
) |>
mutate(
cs_01 = response_duration < 120,
cs_02 = response_duration < 180,
cs_03 = ps_discrete >= 20,
cs_04 = ps_discrete >= 10 | response_duration < 120) |>
step_cleaning_overview(starts_with("cs_"), .cols_group = d_urban)
get_cleaning_overview(x)
} # }