Recode variables and their values based on a data dictionary
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.
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
)
}
# }