convert_parameters {W4MRUtils} | R 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.
[Package W4MRUtils version 1.0.0 Index]