# NOT RUN {
var_label(iris$Sepal.Length)
var_label(iris$Sepal.Length) <- 'Length of the sepal'
# }
# NOT RUN {
View(iris)
# }
# NOT RUN {
# To remove a variable label
var_label(iris$Sepal.Length) <- NULL
# To change several variable labels at once
var_label(iris) <- c(
"sepal length", "sepal width", "petal length",
"petal width", "species"
)
var_label(iris)
var_label(iris) <- list(
Petal.Width = "width of the petal",
Petal.Length = "length of the petal"
)
var_label(iris)
var_label(iris, unlist = TRUE)
if (require(dplyr)) {
# adding some variable labels
df <- tibble(s1 = c("M", "M", "F"), s2 = c(1, 1, 2)) %>%
set_variable_labels(s1 = "Sex", s2 = "Yes or No?")
var_label(df)
# removing a variable label
df <- df %>% set_variable_labels(s2 = NULL)
var_label(df$s2)
# defining variable labels derived from variable names
if (require(snakecase)) {
iris <- iris %>%
set_variable_labels(.labels = to_sentence_case(names(iris)))
var_label(iris)
}
}
# }
Run the code above in your browser using DataLab