util_assign_levlabs: utility function to assign labels to levels

View source: R/util_assign_levlabs.R

util_assign_levlabsR Documentation

utility function to assign labels to levels

Description

function to assign labels to levels of a variable

Usage

util_assign_levlabs(
  variable,
  string_of_levlabs,
  splitchar,
  assignchar,
  ordered = TRUE,
  variable_name = "",
  warn_if_inadmissible = TRUE
)

Arguments

variable

vector vector with values of a study variable

string_of_levlabs

character len=1. value labels, e.g. 1 = no | 2 = yes

splitchar

character len=1. splitting character(s) in string_of_levlabs, usually SPLIT_CHAR

assignchar

character len=1. assignment operator character(s) in string_of_levlabs, usually = or ⁠: ⁠

ordered

the function converts variable to a factor, by default to an ordered factor assuming LHS of assignments being meaningful numbers, e.g. 1 = low | 2 = medium | 3 = high. If no special order is given, set ordered to FALSE, e.g. for 1 = male | 2 = female or 1 = low | 2 = high | 3 = medium.

variable_name

character the name of the variable being converted for warning messages

warn_if_inadmissible

logical warn on con_inadmissible_categorical values

Value

a data.frame with labels assigned to categorical variables (if available)


dataquieR documentation built on July 26, 2023, 6:10 p.m.