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")
(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.
(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
.
(character(1)
)
Number format for output of numeric parameters. See the details section of
the manual for base::sprintf()
for details.
character(1)
.
p = makeNumericParam("x")
paramValueToString(p, 1)
#> [1] "1"
paramValueToString(p, 1.2345)
#> [1] "1.23"
paramValueToString(p, 0.000039)
#> [1] "3.9e-05"
paramValueToString(p, 8.13402, num.format = "%.2f")
#> [1] "8.13"
p = makeIntegerVectorParam("x", len = 2)
paramValueToString(p, c(1L, 2L))
#> [1] "1,2"
p = makeLogicalParam("x")
paramValueToString(p, TRUE)
#> [1] "TRUE"
p = makeDiscreteParam("x", values = list(a = NULL, b = 2))
paramValueToString(p, NULL)
#> [1] "a"
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"