labs_apply {volker}R Documentation

Set variable labels by setting their comment attributes

Description

[Experimental]

Usage

labs_apply(data, codes, cols = NULL, values = TRUE)

Arguments

data

A tibble.

codes

A tibble in codebook format. To set column labels, use item_name and item_label columns.

cols

A tidy column selection. Set to NULL (default) to apply to all columns found in the codebook. Restricting the columns is helpful when you want to set value labels. In this case, provide a tibble with value_name and value_label columns and specify the columns that should be modified.

values

If TRUE (default), sets value labels. - For factors: Factor levels and order are retrieved from the value_label column. - For item values: they are retrieved from both the columns value_name and value_label in your codebook.

Value

A tibble with new labels.

Examples

library(tibble)
library(volker)

newlabels <- tribble(
  ~item_name,                 ~item_label,
 "cg_adoption_advantage_01", "Allgemeine Vorteile",
 "cg_adoption_advantage_02", "Finanzielle Vorteile",
 "cg_adoption_advantage_03", "Vorteile bei der Arbeit",
 "cg_adoption_advantage_04", "Macht mehr Spaß"
 )

 volker::chatgpt %>%
   labs_apply(newlabels) %>%
   tab_metrics(starts_with("cg_adoption_advantage_"))

[Package volker version 2.0.1 Index]