add_labels()
adds labels for selected variables such as sex
, cancer
,
and areacode
in the dataset based on the specified language and label type.
add_labels(
x,
vars = c("sex", "cancer", "areacode"),
label_type = "full",
lang = "zh",
as_factor = TRUE
)
A data frame or tibble to be labeled.
A character vector of variable names to label. Default includes
"sex"
, "cancer"
, and "areacode"
.
Type of the label used ("full" or "abbr").
Character, specify the output language, options are 'cn', or 'en', default is 'cn'.
Logical, indicate whether output value as factor.
A data frame or tibble with labeled variables and reordered columns.
data("canregs")
asr <- create_asr(canregs[[1]], year, sex, cancer)
asr <- add_labels(asr, label_type = "full", lang = "zh")
asr <- add_labels(asr, label_type = "full", lang = "en")