Read a data dictionary from file, attach to a dataset (plus utility functions). These can then be used by other methods (such as plots) to automatically create axes, etc.
read_dictionary(
file,
name = "name",
type = "type",
title = "title",
description = "description",
units = "units",
codes = "codes",
values = "values",
level_separator = "|",
...
)# S3 method for dictionary
print(x, kable = FALSE, include_other = TRUE, ...)
# S3 method for dictionary
[(x, i, ...)
apply_dictionary(data, dict)
has_dictionary(data)
get_dictionary(data)
path to a file
name of the column containing the variable name
column containing the variable type
the column containing a short, human-readable title for the variable - if blank, the variable name will be used instead
name of the column containing the variable description
column containing units (for numeric variables only)
column containing factor codes
column containing factor values - these should be in the same order
the separator used to separate levels in codes
and values
columns, default "|". Can optionally be a vector of length 2, in which case the first is used for codes
and the second for values
.
additional arguments, passed to smart_read
a dictionary
object
if TRUE
outputs a kable instead
if TRUE
additional variables will be included in the output
Subset index
a dataset (dataframe, tibble)
a dictionary (created using read_dictionary()
)
For numeric variables, the dictionary can specify the units used in the measurements.
For categorical variables, often these are coded rather than printed in full in the dataset. Data dictionaries may specify a column containing the codes (with a separator) and