Skip to contents

Turns the mangled column names survey tools produce back into the wording a reader expects: "Broadcast.quality...audio" becomes "Broadcast quality / audio". Drop a question prefix at the same time with prefix, so a block of ratings_* columns becomes plain feature names.

Usage

clean_label(x, prefix = NULL)

Arguments

x

A character vector of column names.

prefix

Optional prefix to strip from the start of each name before tidying, e.g. "ratings_". Names that do not start with it are left alone.

Value

A character vector of labels, the same length as x.

Details

Exporters replace every character they cannot put in a column name with a dot, so a slash surrounded by spaces arrives as three dots and a space arrives as one. This restores both, in that order, then squishes the result. It is the same cleaning calc_percentage_multi() and ipm_model() apply to their own output, exported so a hand-built table can match them: labels that disagree will not join, which is what silently empties a comparison chart.

Examples

clean_label("Broadcast.quality...audio")
#> [1] "Broadcast quality / audio"

clean_label(c("ratings_Camera.work", "ratings_Talent...analysis"),
            prefix = "ratings_")
#> [1] "Camera work"       "Talent / analysis"