convert_parameters: Convert Parameters

View source: R/miniTools.R

convert_parametersR Documentation

Convert Parameters

Description

convert_parameters Applies a list of converters to each values on a list. If a value is modified during the conversion (successfull conversion) then, no further convert will be applied to this value, so values are only converted once.

Usage

convert_parameters(args, converters)

Arguments

args

a named list, which values will be converted.

converters

a vector of function. Each function will be applied to each values with the exception of values already converted by a previous converter.

Value

a named list object with values converted by converters.

Author(s)

L.Pavot

Examples

boolean_converter <- function(x) {
  return(if (x == "TRUE") TRUE else if (x == "FALSE") FALSE else x)
}
parameters <- W4MRUtils::convert_parameters(
  list("x" = "TRUE"),
  c(boolean_converter)
)
print(parameters$`some-parameter`)
## "TRUE" has becomes TRUE.


W4MRUtils documentation built on Sept. 8, 2023, 5:11 p.m.