Skip to contents

Given a dataframe of survey responses, reverse engineer skip rules based on completion patterns (and optionally user input) in order to distinguish/re-code "Not applicable" NA values from "No answer" NA values.

Usage

find_skip_rules(
  data,
  interactive = TRUE,
  skip_rule_val = NA,
  no_answer_val = "No answer"
)

Arguments

data

input survey data frame of responses (note: function only guaranteed to work if this is the output from parse_survey).

interactive

if set to TRUE, detect possible skip rules and ask before re-coding responses; else automatically detect rules and re-code responses.

skip_rule_val

what to code question responses where the respondent never saw the question due to a skip rule (default is NA which tends to play nicely with banner and cross-tab creation).

no_answer_val

what to code question responses where the respondent saw the question and did not answer (default is "No answer"). By default, retrieved from get_token().

Value

A survey response dataframe with NAs distinguished between "Not applicable" responses from "No answer" responses.

Details

Note: if skip_rule_val or no_answer_val are set to character strings, the corresponding factor variables (in the relevant question columns) will be expanded via the forcats library to include those values as levels.