Learn R Programming

iNZightTools (version 1.13.0)

read_dictionary: Data dictionaries

Description

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.

Usage

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)

Arguments

file

path to a file

name

name of the column containing the variable name

type

column containing the variable type

title

the column containing a short, human-readable title for the variable - if blank, the variable name will be used instead

description

name of the column containing the variable description

units

column containing units (for numeric variables only)

codes

column containing factor codes

values

column containing factor values - these should be in the same order

level_separator

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

x

a dictionary object

kable

if TRUE outputs a kable instead

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())

Units and codes

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