Dictionary {oeli} | R Documentation |
Dictionary R6 Object
Description
Provides a simple key-value interface based on R6.
Active bindings
keys
[
character()
]
Available keys.alias
[
list()
]
Available keys per alias value.
Methods
Public methods
Method new()
Initializing a new Dictionary
object.
Usage
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 )
Arguments
key_name
[
character(1)
]
The name for the key variable.alias_name
[
NULL
|character(1)
]
Optionally the name for the alias variable.value_names
[
character(0)
]
The names of the values connected to a key.value_assert
[
alist(1)
]
For each element invalue_names
,values_assert
can have an identically named element of the formcheckmate::assert_*(...)
, where...
can be any argument for the assertion function except for thex
argument.allow_overwrite
[
logical(1)
]
Allow overwriting existing keys with new values? Duplicate keys are never allowed.keys_reserved
[
character()
]
Names that must not be used as keys.alias_choices
[
NULL
orcharacter()
]
Optionally possible values for the alias. Can also beNULL
, then all alias values are allowed.dictionary_name
[
NULL
orcharacter()
]
Optionally the name for the dictionary.
Method add()
Adding an element to the dictionary.
Usage
Dictionary$add(...)
Arguments
...
Values for
the key variable
key_name
(must be a singlecharacter
),the alias variable
alias_name
(optionally, must then be acharacter
vector
),all the variables specified for
value_names
(if any, they must comply to thevalue_assert
checks).
Method get()
Getting elements from the dictionary.
Usage
Dictionary$get(key, value = NULL)
Arguments
key
[
character(1)
]
A value for the key variablekey_name
. Use the$keys
method for available keys.value
[
NULL
|character(1)
]
One of the elements invalue_names
, selecting the required value. Can also beNULL
(default) for all values connected to thekey
, returned as alist
.
Method remove()
Removing elements from the dictionary (and associated alias, if any).
Usage
Dictionary$remove(key)
Arguments
key
[
character(1)
]
A value for the key variablekey_name
. Use the$keys
method for available keys.
Method print()
Printing details of the dictionary.
Usage
Dictionary$print()
See Also
Other package helpers:
Storage
,
identical_structure()
,
input_check_response()
,
match_arg()
,
package_logo()
,
print_data.frame()
,
print_matrix()
,
renv_development_packages()
,
system_information()
,
unexpected_error()
,
user_confirm()
Examples
# TODO