decode_preview.RdDecodes coded columns in a mortality dataset using a metadata table, returning original and decoded columns side by side for inspection. Useful for quickly verifying that codes are mapping correctly before committing to a full decode.
decode_preview(
data,
meta,
first_n = 5,
numbers = NULL,
n_rows = 1000,
all = FALSE
)A data frame of mortality records, typically loaded via
read_fwf() using a metadata table from this package.
A metadata tibble with at minimum columns name and
codes, such as data_mortality_multiple_1969.
Integer. Number of coded columns to decode, starting from
the first column in meta that has codes. Default is 5.
Integer vector. Additional column indices from meta
to decode. Overlaps with first_n are silently deduplicated with
a warning. Columns with no codes are skipped with a warning.
Integer. Number of rows to return. Default is 1000.
Use nrow(data) for a full decode.
Logical. If TRUE, decodes all coded columns and returns
all columns in metadata order with decoded values replaced in place.
Overrides first_n and numbers. Default is FALSE.
A tibble. When all = FALSE, returns only the selected
columns with each original column immediately followed by its decoded
_label counterpart. When all = TRUE, returns all columns
in metadata order with coded columns decoded in place.
if (FALSE) { # \dontrun{
meta <- data_mortality_multiple_1969
# first 5 coded columns, 1000 rows
decode_preview(mort1969, meta)
# first 10 coded columns
decode_preview(mort1969, meta, first_n = 10)
# first 5 coded + column 17
decode_preview(mort1969, meta, numbers = 17)
# first 3 coded columns + columns 12 and 20 specifically
decode_preview(mort1969, meta, first_n = 3, numbers = c(12, 20))
# decode everything, replace in place
decode_preview(mort1969, meta, all = TRUE)
# full decode of entire dataset
mort1969_decoded <- decode_preview(mort1969, meta, all = TRUE, n_rows = nrow(mort1969))
} # }