| tidy_labels {sjlabelled} | R Documentation |
Duplicated value labels in variables may cause troubles when
saving labelled data, or computing cross tabs (cf.
flat_table or sjp.xtab).
tidy_labels() repairs duplicated value labels by suffixing
them with the associated value.
tidy_labels(x, ..., sep = "_", remove = FALSE)
x |
A vector or data frame. |
... |
Optional, unquoted names of variables that should be selected for
further processing. Required, if |
sep |
String that will be used to separate the suffixed value from the old label when creating the new value label. |
remove |
Logical, if |
x, with "repaired" (unique) value labels for each variable.
library(sjmisc)
x <- set_labels(
sample(1:5, size = 20, replace = TRUE),
labels = c("low" = 1, ".." = 2, ".." = 3, ".." = 4, "high" = 5)
)
frq(x)
z <- tidy_labels(x)
frq(z)
z <- tidy_labels(x, sep = ".")
frq(z)
z <- tidy_labels(x, remove = TRUE)
frq(z)