Skip to contents

This functions allows to add a label to var. It's useful for the graphics or the reports. Obviously, this function can be applied only if a metadata exists

Usage

label(
  var,
  metadata,
  var_field = "var",
  label_field = "LABEL",
  include_varname = FALSE
)

Arguments

var

character - the name of the var(s) that we want to replace by the label, could be a vector

metadata

data.frame - if we have a metadata loaded in your R, you can use to take the label of the vars.

var_field

- character: name of the column in metadata that contains variable name (default: 'var')

label_field

- character: name of the column in metadata that contains variable label (default: 'LABEL')

include_varname

- logical. If returned string will also include variables names within brackets after label for variables that has label. (default: FALSE).

Value

a label

Examples

if (FALSE) { # \dontrun{
label(adult$EDUCATIONNUM, metadata=mymetadata) # assumes mymetadata dataframe exists
} # }