Dict {collections} | R Documentation |
The Dict
class creates an ordinary (unordered) dictionary.
The key-value pairs are stored in an R environment.
Dict
An object of class R6ClassGenerator
of length 24.
Dict$new(items = NULL) Dict$set(key, value) Dict$get(key, default) Dict$remove(key) Dict$pop(key, default) Dict$has(key) Dict$keys() Dict$values() Dict$update(d) Dict$clear() Dict$size() Dict$as_list()
items
: initialization list
key
: any R object, key of the item
value
: any R object, value of the item
default
: optional, the default value of an item if the key is not found
d <- Dict$new(list(apple = 5, orange = 10)) d$set("banana", 3) d$get("apple") d$as_list() # unordered d$pop("orange") d$as_list() # "orange" is removed d$set("orange", 3)$set("pear", 7) # chain methods