# Retrieve the label attribute
var_label(orange_df$circumference)
# Set or update the label attribute
var_label(orange_df$circumference) <- "circumference (breast height)"
# Example: Retrieve variable labels from a dataset_df
df <- dataset_df(
id = defined(1:3, label = "Observation ID"),
temp = defined(c(22.5, 23.0, 21.8), label = "Temperature (°C)"),
site = defined(c("A", "B", "A"))
)
# List form (default)
var_label(df)
# Character vector form
var_label(df, unlist = TRUE, null_action = "empty")
# Exclude variables without labels
var_label(df, null_action = "skip")
# Replace missing labels with column names
var_label(df, null_action = "fill")
Run the code above in your browser using DataLab