| var_labels | R Documentation |
Assign labels to describe variables in a data frame. Can be called on a single variable or full data, to assign or to read existing labels.
var_labels(x)
var_labels(x) <- value
x |
A vector or a data frame. |
value |
Character label(s) to assign. |
For a vector, this reads/writes a base-R "label" attribute.
For a data frame, this reads/writes the "label" attribute of each
column.
- If x is a data frame: a named character vector with one entry per
column (missing labels are returned as NA_character_).
- Otherwise: a single character string (or NA_character_).
df <- data.frame(x = 1:3, y = 4:6)
# Set labels for all columns
var_labels(df) <- c("this is x", "this is y")
var_labels(df)
# Set a label for a single column
var_labels(df$x) <- "this is x"
var_labels(df$x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.