apply_dic: Apply dictionary

View source: R/apply_dic.R

apply_dicR Documentation

Apply dictionary

Description

Joins a data frame with a dictionary file.

Usage

apply_dic(
  data,
  dic,
  factors = TRUE,
  set_label_attr = TRUE,
  coerce_class = TRUE,
  replace_missing = TRUE,
  score_scales = TRUE,
  check_values = FALSE,
  impute_values = FALSE,
  rename_var = NULL
)

Arguments

data

Data frame

dic

A data frame comprising a dictionary or a character string with a filename (for now an Microsoft Excel file) containing a dictionary.

factors

If set TRUE, variables defined as type factor in the dic file will be turned into factors.

set_label_attr

If TRUE, label attributes from the haven package are set. These labels are shown in the Rstudio View panel.

coerce_class

If set TRUE mismatches between class and dic type are corrected.

replace_missing

If TRUE, missing values from the dic are replaced with NA

score_scales

If TRUE and the dic files contains score scale definitions these are applied

check_values

If TRUE, performs the check_values function on the variables of the data frame included in the dic file.

impute_values

If TRUE and score_scales is TRUE, missing values are automatically imputed based on scale information provided in the dic file.

rename_var

When a character is provided, corresponding column from the dic file is used to rename variables from rename_var to item_name.

Value

A data frame with dictionary information.

Examples

dat <- apply_dic(dat_itrf, dic_itrf)
descriptives(dat)

jazznbass/scaledic documentation built on July 19, 2023, 12:50 a.m.