Learn R Programming

ParamHelpers (version 1.1-36)

trafoValue: Transform a value.

Description

Transform a value with associated transformation function(s).

Usage

trafoValue(par, x)

Arguments

par
[Param | ParamSet] Parameter or parameter set.
x
[any] Single value to check. For a parameter set this must be a list in the correct order.

Value

  • Transformed value.

Examples

Run this code
# transform simple parameter:
p <- makeNumericParam(id="x", trafo=function(x) x^2)
trafoValue(p, 2)
# for a parameter set different transformation functions are possible:
ps <- makeParamSet(
  makeIntegerParam("u", trafo=function(x) 2*x),
  makeNumericVectorParam("v", len=2, trafo=function(x) x/sum(x)),
  makeDiscreteParam("w", values=c("a", "b"))
)
# now the values of "u" and "v" are transformed:
trafoValue(ps, list(3, c(2, 4), "a"))

Run the code above in your browser using DataLab