prep_get_labels function

Fetch a label for a variable based on its purpose

Fetch a label for a variable based on its purpose

prep_get_labels( resp_vars, item_level = "item_level", label_col, max_len = MAX_LABEL_LEN, label_class = c("SHORT", "LONG"), label_lang = getOption("dataquieR.lang", ""), resp_vars_are_var_names_only = FALSE, resp_vars_match_label_col_only = FALSE, meta_data = item_level, meta_data_v2, force_label_col = getOption("dataquieR.force_label_col", dataquieR.force_label_col_default) )

Arguments

  • resp_vars: variable list the variable names to fetch for

  • item_level: data.frame the data frame that contains metadata attributes of study data

  • label_col: variable attribute the name of the column in the metadata with labels of variables

  • max_len: integer the maximum label length to return, if not possible w/o causing ambiguous labels, the labels may still be longer

  • label_class: enum SHORT | LONG. which sort of label according to the metadata model should be returned

  • label_lang: character optional language suffix, if available in the metadata. Can be controlled by the option dataquieR.lang.

  • resp_vars_are_var_names_only: logical If TRUE, do not use other labels than VAR_NAMES

    for finding resp_vars in meta_data

  • resp_vars_match_label_col_only: logical If TRUE, do not use other labels than those, referred by label_col

    for finding resp_vars in meta_data

  • meta_data: data.frame old name for item_level

  • meta_data_v2: character path to workbook like metadata file, see prep_load_workbook_like_file for details. ALL LOADED DATAFRAMES WILL BE PURGED , using prep_purge_data_frame_cache, if you specify meta_data_v2.

  • force_label_col: enum auto | FALSE | TRUE. if TRUE, always use labels according label_col, FALSE means use labels matching best the function's requirements, auto means FALSE, if in a dq_report() and TRUE, otherwise.

Returns

character suitable labels for each resp_vars, names of this vector are VAR_NAMES

Examples

## Not run: prep_load_workbook_like_file("meta_data_v2") prep_get_labels("SEX_0", label_class = "SHORT", max_len = 2) ## End(Not run)
  • Maintainer: Stephan Struckmann
  • License: BSD_2_clause + file LICENSE
  • Last published: 2025-03-05