Adds parameters to argument list if list does not already include those parameters

add_arg_if(args, ..., override = FALSE)

Arguments

args

Argument list

...

Other named arguments are added (depending on override) and returned with args

override

Logical indicating whether to override existing values in args with the values provided as a named argument here.

Value

Argument list with updated values.

Examples

## arg list args <- list(x = 5, y = TRUE, z = FALSE) ## add arg defaults add_arg_if(args, w = TRUE, z = TRUE)
#> $x #> [1] 5 #> #> $y #> [1] TRUE #> #> $z #> [1] FALSE #> #> $w #> [1] TRUE #>
## add arg defaults, overriding any previous values add_arg_if(args, x = 10, z = TRUE, override = TRUE)
#> $x #> [1] 10 #> #> $y #> [1] TRUE #> #> $z #> [1] TRUE #>