This function reads a data dictionary from a file and attaches it to a dataset. The attached data dictionary provides utility functions that can be used by other methods, such as plots, to automatically create axes and more.
Usage
read_dictionary(
file,
name = "name",
type = "type",
title = "title",
description = "description",
units = "units",
codes = "codes",
values = "values",
level_separator = "|",
...
)
# S3 method for class 'dictionary'
print(x, kable = FALSE, include_other = TRUE, ...)
# S3 method for class 'dictionary'
x[i, ...]
apply_dictionary(data, dict)
has_dictionary(data)
get_dictionary(data)
Arguments
- file
The path to the file containing the data dictionary.
- name
The name of the column containing the variable name.
- type
The name of the column containing the variable type.
- title
The name of the column containing a short, human-readable title for the variable. If blank, the variable name will be used instead.
- description
The name of the column containing the variable description.
- units
The name of the column containing units (for numeric variables only).
- codes
The name of the column containing factor codes (for categorical variables only).
- values
The name of the column containing factor values corresponding to the codes. These should be in the same order as the codes.
- level_separator
The separator used to separate levels in
codes
andvalues
columns. The default separator is "|". Alternatively, you can provide a vector of length 2, where the first element is used forcodes
and the second element forvalues
.- ...
Additional arguments, passed to
smart_read
.- x
A
dictionary
object.- kable
If
TRUE
, the output will be formatted using kable.- include_other
If
TRUE
, additional variables will be included in the output.- i
Subset index.
- data
A dataset (dataframe, tibble).
- dict
A dictionary (created using
read_dictionary()
).