use_labels: Use the data labels of a variable instead of its values...

View source: R/Labels.R

use_labelsR Documentation

Use the data labels of a variable instead of its values [Experimental]

Description

Use the data labels of a variable instead of its values [Experimental]

Usage

use_labels(tbl, dict, vars = NULL, ignore_case = F, check = TRUE, warn = TRUE)

Arguments

tbl

data.frame: Data.frame with the data

dict

data.frame: Dictionary with all the data labels to use if they have not yet been assigned. See Details

vars

character: If specified, only labels are assigned to those variables

ignore_case

logical: Indicate if case sensitive should be ignored

check

logical: If TRUE (default), the function will check if values present in variable are valid data labels in dictionary.

warn

logical: Indicate if warnings should be shown.

Details

This function assumes that the data labels have been assigned to the data before, unless a dict is supplied, in which case the latter will be used to assign and use the data labels.

Value

The data supplied in the tbl argument, but instead of values using the corresponding data labels

See Also

Data labels vignette("labeler", package = "labeler")

Examples

## Not run: 
dict <- list(
  SEX = list(
    lab = "Sex of the person",
    labs = c(
      "Man" = 1,
      "Woman" = 2
    )
  )
)
enft <- data.frame(SEX = c(1, 2))
enft
use_labels(enft, dict = dict)

## End(Not run)

adatar-do/labeler documentation built on Sept. 19, 2024, 2:50 p.m.