update_variable_labels_with {labelled}R Documentation

Update variable/value labels with a function

Description

Update variable/value labels with a function

Usage

update_variable_labels_with(.data, .fn, .cols = dplyr::everything(), ...)

update_value_labels_with(.data, .fn, .cols = dplyr::everything(), ...)

Arguments

.data

A data frame, or data frame extension (e.g. a tibble)

.fn

A function used to transform the variable/value labels of the selected .cols.

.cols

Columns to update; defaults to all columns. Use tidy selection.

...

additional arguments passed onto .fn.

Examples

df <- iris %>%
  set_variable_labels(
    Sepal.Length = "Length of sepal",
    Sepal.Width = "Width of sepal",
    Petal.Length = "Length of petal",
    Petal.Width = "Width of petal",
    Species = "Species"
  )
df$Species <- to_labelled(df$Species)
df %>% look_for()
df %>%
  update_variable_labels_with(toupper) %>%
  look_for()
df %>%
  update_variable_labels_with(toupper, .cols = dplyr::starts_with("S")) %>%
  look_for()
df %>%
  update_value_labels_with(toupper) %>%
  look_for()

[Package labelled version 2.13.0 Index]