getDefaults: Return defaults of parameters in parameter set.

Description Usage Arguments Value Examples

View source: R/getDefaults.R

Description

Return defaults of single parameters or parameters in a parameter set or a list of parameters.

Usage

1
getDefaults(obj, include.null = FALSE, dict = NULL)

Arguments

obj

(Param() | ParamSet() | list)
Parameter, parameter set or list of parameters, whose defaults should be extracted. In case the default values contain expressions, they will be evaluated using the provided dictionary (dict).

include.null

(logical(1))
Include NULL entries for parameters without default values in the result list? Note that this can be slightly dangerous as NULL might be used as default value for other parameters. Default is FALSE.

dict

(environment | list | NULL)
Environment or list which will be used for evaluating the variables of expressions within a parameter, parameter set or list of parameters. The default is NULL.

Value

named list. Named (and in case of a ParamSet(), in the same order). Parameters without defaults are not present in the list.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
ps1 = makeParamSet(
  makeDiscreteParam("x", values = c("a", "b"), default = "a"),
  makeNumericVectorParam("y", len = 2),
  makeIntegerParam("z", default = 99)
)
getDefaults(ps1, include.null = TRUE)

ps2 = makeParamSet(
  makeNumericVectorParam("a", len = expression(k), default = expression(p)),
  makeIntegerParam("b", default = 99),
  makeLogicalParam("c")
)
getDefaults(ps2, dict = list(k = 3, p = 5.4))

ParamHelpers documentation built on March 26, 2020, 7:40 p.m.