Build a single {}
expression that defines inputs for a simulation.
Named args in
...
become assignments (name <- expr
), e.g.,add_item(a=5)
Unnamed args are inserted raw/unevaluated. If an unnamed arg is a
{}
block, its statements are spliced (flattened).add_item(pick_val_v(...))
Works with magrittr pipes: a leading
.
(the LHS) is resolved to its value; if that value is a{}
block (or list of expressions), it becomes the starting block.input argument can be used to handle alternative
add_item2
method, e.g.add_item(input = {a <- 5})
Value
A single {}
call (language object) ready for load_inputs()
.
Examples
library(magrittr)
add_item(input = {fl.idfs <- 0})
#> {
#> fl.idfs <- 0
#> }
add_item(input = {
util_idfs <- if(psa_bool){rnorm(1,0.8,0.2)} else{0.8}
util.mbc <- 0.6
cost_idfs <- 2500})
#> {
#> util_idfs <- if (psa_bool) {
#> rnorm(1, 0.8, 0.2)
#> }
#> else {
#> 0.8
#> }
#> util.mbc <- 0.6
#> cost_idfs <- 2500
#> }
common_inputs <- add_item(input = {
pick_val_v(
base = l_statics[["base"]],
psa = pick_psa(
l_statics[["function"]],
l_statics[["n"]],
l_statics[["a"]],
l_statics[["b"]]
),
sens = l_statics[[sens_name_used]],
psa_ind = psa_bool,
sens_ind = sensitivity_bool,
indicator = indicators_statics,
names_out = l_statics[["parameter_name"]],
deploy_env = TRUE #Note this option must be active if using it at add_item2
)
}
)