Extract a question label or response levels while collecting MR columns
Source:R/multiple_response.R
collect_mr_label_default.RdThese functions supply the label and levels arguments to collect_mr().
Each receives a named list of the original component columns, with attributes
intact. Label helpers return one string or NULL; levels helpers return one
string per component or NULL when that strategy cannot extract valid levels.
The default helpers try survey metadata, then longest common prefix (LCP),
then fallback. Metadata helpers read the metadata attribute assigned by
g6tr.survey step functions: question and template_elements$option.
No dependency on g6tr.survey is required.
LCP helpers use component label attributes. The common prefix is trimmed
at word boundaries and trailing separators are removed from the question label.
Levels come from the remaining text. A single component skips LCP extraction.
Fallback levels use complete component labels, or source names if labels are
missing or duplicated. The fallback question label uses an identical label
shared by all components, otherwise returns NULL.
Usage
collect_mr_label_default(columns)
collect_mr_levels_default(columns)
collect_mr_label_metadata(columns)
collect_mr_levels_metadata(columns)
collect_mr_label_lcp(columns)
collect_mr_levels_lcp(columns)
collect_mr_label_fallback(columns)
collect_mr_levels_fallback(columns)