param_printer <- function(name, args) {
sprintf(
"%s[%s] %s",
name,
class(args[[name]])[1],
paste(args[[name]], collapse = " ")
)
}
args <- W4MRUtils::parse_args(commandArgs())
#> Warning in W4MRUtils::parse_args(commandArgs()): Please, use the 'optparse'
#> library instead of the 'parse_args' function.
args
#> $a_integer
#> [1] 42
#>
#> $a_float
#> [1] 3.14
#>
#> $a_boolean
#> [1] FALSE
#>
#> $a_list
#> [1] "1,2,3"
param_printer("a_integer", args)
#> [1] "a_integer[numeric] 42"
param_printer("a_float", args)
#> [1] "a_float[numeric] 3.14"
param_printer("a_boolean", args)
#> [1] "a_boolean[logical] FALSE"
param_printer("a_list", args)
#> [1] "a_list[character] 1,2,3"
args$a_list <- as.numeric(strsplit(args$a_list, ",")[[1]])
param_printer("a_list", args)
#> [1] "a_list[numeric] 1 2 3"