paramValueToString: Convert a value to a string.

Description Usage Arguments Value Examples

View source: R/paramValueToString.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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))

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