Learn R Programming

tfse (version 0.5.0)

add_arg_if: Add defaults to argument list

Description

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

Usage

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

Run this code
# NOT RUN {
## arg list
args <- list(x = 5, y = TRUE, z = FALSE)

## add arg defaults
add_arg_if(args, w = TRUE, z = TRUE)

## add arg defaults, overriding any previous values
add_arg_if(args, x = 10, z = TRUE, override = TRUE)

# }

Run the code above in your browser using DataLab