Useful helper for logging. For discrete parameter values always the name of the discrete value is used.

paramValueToString(par, x, show.missing.values = FALSE, num.format = "%.3g")

Arguments

par

(Param | ParamSet)
Parameter or parameter set.

x

(any)
Value for parameter or value for parameter set. In the latter case it must be named list. For discrete parameters their values must be used, not their names.

show.missing.values

(logical(1))
Display “NA” for parameters, which have no setting, because their requirements are not satisfied (dependent parameters), instead of displaying nothing? Default is FALSE.

num.format

(character(1))
Number format for output of numeric parameters. See the details section of the manual for base::sprintf() for details.

Value

character(1).

Examples

p = makeNumericParam("x") paramValueToString(p, 1) paramValueToString(p, 1.2345) paramValueToString(p, 0.000039) paramValueToString(p, 8.13402, num.format = "%.2f") p = makeIntegerVectorParam("x", len = 2) paramValueToString(p, c(1L, 2L)) p = makeLogicalParam("x") paramValueToString(p, TRUE) p = makeDiscreteParam("x", values = list(a = NULL, b = 2)) paramValueToString(p, NULL) ps = makeParamSet( makeNumericVectorParam("x", len = 2L), makeDiscreteParam("y", values = list(a = NULL, b = 2)) ) paramValueToString(ps, list(x = c(1, 2), y = NULL))
#> [1] "x=1,2; y=a"