labels.code | R Documentation |
Convert vector with codes to factor using a code list
## S3 method for class 'code'
labels(
object,
missing = TRUE,
droplevels = FALSE,
codelist = attr(object, "codelist"),
locale = cl_locale(codelist),
...
)
to_labels(
x,
codelist = attr(x, "codelist"),
missing = TRUE,
droplevels = FALSE,
locale = cl_locale(codelist)
)
object |
vector with codes. Should be of the same type as the codes in the codelist. |
missing |
convert codes that are missing value to missing values. |
droplevels |
remove labels that do not occur in |
codelist |
a |
locale |
use the codes from the given locale. Should be character vector of length 1. |
... |
ignored |
x |
vector with codes. Should be of the same type as the codes in the codelist. |
to_labels
calls labels.code
directly and is meant as a
substitute for labels.code
for objects that are not of type 'code'.
A factor vector with the same length as x
.
data(objectsales)
data(objectcodes)
objectsales$product <- code(objectsales$product, objectcodes)
labels(objectsales$product) |>
table(useNA = "ifany")
labels(objectsales$product, missing = FALSE) |>
table(useNA = "ifany")
labels(objectsales$product, droplevels = TRUE) |>
table(useNA = "ifany")
to_labels(c("A", "B"), codelist = objectcodes)
# is the same as
labels.code(c("A", "B"), codelist = objectcodes)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.