This function creates a single subvariable definition based on a character string to search for and an originating variable. It uses regex to determine whether a string is present in a delimited list, then substitutes the user supplied values to indicate selection, non-selection, and missingness.
createSubvarDeriv(var, str, delim, selected, not_selected, unanswered)
A VariableDefinition
The variable containing the delimited responses
A string whose presence indicates a selection
The delimiter separating the responses
A character string used to indicate a selection, defaults to "selected"
Character string identifying non-selection, defaults to "not_selected"
Character string indicating non-response, defaults to NA.