Skip to contents

Inverse of irw_recode(): maps codes such as I0001 back to the original identifier values using the recode key.

Usage

irw_decode(x, key = NULL, cols = NULL)

Arguments

x

A data frame returned by irw_recode(), or derived from one (including the wide result of irw_long2resp()).

key

A recode key as returned by irw_recode_key(). Defaults to the key attached to x; supply it explicitly if the attribute was dropped.

cols

Character vector of columns to decode. Defaults to all columns present in both x and the key.

Value

x with codes replaced by the original values and the "irw_recode_key" attribute removed.

Details

Works on long-format data (columns named in the key are decoded in place) and on the wide output of irw_long2resp(), where item codes appear as column names. irw_long2resp() prefixes item columns with item_; that prefix is handled and preserved. Values or column names that are not found in the key are left untouched.