Skip to contents

Recode variables and their values based on a data dictionary

Usage

recode_vrs(data, data_dictionary, vrs = NULL, factor = FALSE)

Arguments

data

A data frame with raw data.

data_dictionary

A data dictionary containing labels for variables and their values.

vrs

A character vector specifying variables of which the values need to be recoded.

factor

A logical to indicate whether recoded variables need to be converted into ordered factors.

Value

The input data frame with recoded and labelled variables.

Examples

# \donttest{
if (FALSE) {
  library(phdcocktail)
  data(ibd_data1, package = "phdcocktail")
  ibd_data_recoded <- recode_vrs(
    data = ibd_data1, data_dictionary = ibd_data_dict,
    vrs = c("disease_location", "disease_behaviour", "gender"), factor = TRUE
  )
}
# }