Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dictionary_sugar_get

A Quick Way to Initialize Objects from Dictionaries


Description

Given a Dictionary, retrieve objects with provided keys.

  • dictionary_sugar_get() to retrieve a single object with key .key.

  • dictionary_sugar_mget() to retrieve a list of objects with keys .keys.

  • dictionary_sugar() is deprecated in favor of dictionary_sugar_get().

  • If .key or .keys is missing, the dictionary itself is returned.

Arguments in ... must be named and are consumed in the following order:

  1. All arguments whose names match the name of an argument of the constructor are passed to the $get() method of the Dictionary for construction.

  2. All arguments whose names match the name of a parameter of the paradox::ParamSet of the constructed object are set as parameters. If there is no paradox::ParamSet in obj$param_set, this step is skipped.

  3. All remaining arguments are assumed to be regular fields of the constructed R6 instance, and are assigned via <-.

Usage

dictionary_sugar_get(dict, .key, ...)

dictionary_sugar(dict, .key, ...)

dictionary_sugar_mget(dict, .keys, ...)

Arguments

dict

(Dictionary).

.key

(character(1))
Key of the object to construct.

...

(any)
See description.

.keys

(character())
Keys of the objects to construct.

Value

Examples

library(R6)
item = R6Class("Item", public = list(x = 0))
d = Dictionary$new()
d$add("key", item)
dictionary_sugar_get(d, "key", x = 2)

mlr3misc

Helper Functions for 'mlr3'

v0.10.0
LGPL-3
Authors
Michel Lang [cre, aut] (<https://orcid.org/0000-0001-9754-0393>), Patrick Schratz [aut] (<https://orcid.org/0000-0003-0748-6624>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.