Provides a simple key-value interface based on R6.
keysA character vector of available keys.
aliasA list of available keys per alias value.
new()initializing a Dictionary object
Dictionary$new(
key_name,
alias_name = NULL,
value_names = character(),
value_assert = alist(),
allow_overwrite = TRUE,
keys_reserved = character(),
alias_choices = NULL,
dictionary_name = NULL
)key_nameA single character, the name for the key variable.
alias_nameOptionally a single character, the name for the alias variable.
Can also be NULL (default) for no alias.
value_namesA character (vector), the names of the values connected to a
key.
value_assertA alist with check functions for supplied values. For each element
in value_names, values_assert can have an identically named
element of the form checkmate::assert_*(...), where ... can be
any arguments for the assertion function except for the x argument.
allow_overwriteEither TRUE (default) to allow overwriting existing keys with new
values, or FALSE else. Duplicate keys are never allowed.
keys_reservedA character (vector) of names that must not be used as keys.
alias_choicesOptionally a character vector of possible values for the alias.
Can also be NULL, then all alias values are allowed.
dictionary_nameOptionally a single character, a name for the dictionary.
a new Dictionary object
add()adding an element
Dictionary$add(...)...Values for
the key variable key_name (must be a single character),
the alias variable alias_name (optionally, must then be a
character vector),
all the variables specified for value_names (if any, they must
comply to the value_assert checks).
invisibly the Dictionary object
keyA single character, a value for the key variable key_name.
Use the $keys method for available keys.
valueOptionally a single character, one of the elements in
value_names, selecting the required value.
Can also be NULL (default) for all values connected to the
key, returned as a list.
the selected value
keyA single character, a value for the key variable key_name.
Use the $keys method for available keys.
invisibly the Dictionary object
invisibly the Dictionary object