var_label | R Documentation |
Add a human readable, easier to understand label as a metadata attribute to a variable or vector than the programmatic vector object name, or column name in the data frame.
## S3 method for class 'defined'
var_label(x, ...)
## S3 method for class 'dataset_df'
var_label(
x,
unlist = FALSE,
null_action = c("keep", "fill", "skip", "na", "empty"),
recurse = FALSE,
...
)
label_attribute(x)
var_label(x) <- value
## S3 replacement method for class 'haven_labelled_defined'
var_label(x) <- value
## S3 replacement method for class 'dataset_df'
var_label(x) <- value
x |
a vector or a data.frame |
... |
Further arguments passed to or used by methods. |
unlist |
for data frames, return a named vector instead of a list |
null_action |
for data frames, by default |
recurse |
if |
value |
a character string or |
See labelled::var_label
for details about
variable labels.
See vignette("defined", package = "dataset")
to use comprehensively
with variable labels, namespaces, units of measures, and machine-independent
permanent variable identifiers.
var_label()
returns the label
attribute as a character
string. The var_label<-
assignment method allows to add, remove, or
overwrite this attribute on a vector x
. The assignment function returns
the x
vector invisibly.
Other defined metadata methods and functions:
defined()
,
var_namespace()
,
var_unit()
# Retrieve the label attribute:
var_label(orange_df$circumference)
# To (re)set the label attribute:
`var_label<-`(orange_df$circumference, "circumference (breast height)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.