View source: R/labels_to_levels.R
labels_to_levels | R Documentation |
Convert value labels into factor levels
labels_to_levels(x, ...)
## S3 method for class 'factor'
labels_to_levels(x, verbose = TRUE, ...)
## S3 method for class 'data.frame'
labels_to_levels(
x,
select = NULL,
exclude = NULL,
ignore_case = FALSE,
append = FALSE,
regex = FALSE,
verbose = TRUE,
...
)
x |
A data frame or factor. Other variable types (e.g. numerics) are not allowed. |
... |
Currently not used. |
verbose |
Toggle warnings. |
select |
Variables that will be included when performing the required tasks. Can be either
If |
exclude |
See |
ignore_case |
Logical, if |
append |
Logical or string. If |
regex |
Logical, if |
labels_to_levels()
allows to use value labels of factors as their levels.
x
, where for all factors former levels are replaced by their value
labels.
data(efc)
# create factor
x <- as.factor(efc$c172code)
# add value labels - these are not factor levels yet
x <- assign_labels(x, values = c(`1` = "low", `2` = "mid", `3` = "high"))
levels(x)
data_tabulate(x)
x <- labels_to_levels(x)
levels(x)
data_tabulate(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.