check_args()
checks whether the specified arguments are missing.
If any required argument is missing, it generates a descriptive error
message for each missing argument.
Value
The function does not return a value. If any argument is missing, it stops the function execution with an error message listing all missing arguments.
Details
The check_args
function takes a list of arguments (args
) and
a character vector of corresponding argument names (arg_names
).
It checks if any argument is missing and stops the function execution,
providing a message for each missing argument. The args
and
arg_names
vectors must have the same length.
Examples
time_span <- c(0, 2)
try(check_args(list(time_span = time_span), c("time_span", "y0")))
#> Error in check_args(list(time_span = time_span), c("time_span", "y0")) :
#> You must specify all required arguments. Missing arguments: y0
y0 <- 0.5
check_args(list(time_span = time_span, y0 = y0), c("time_span", "y0"))