assert_no_null_arguments | R Documentation |
Sometimes a NULL argument allows a the function to proceed without error, but produces unhelpful, NULL results. This allows the user to reject functions called with NULL arguments if they'll be problematic.
assert_no_null_arguments(as_list_env = NULL)
as_list_env |
[list] as_list_env = as.list(environment()) - default calling environment one level up the call stack |
[std_err] console output of missing arguments
test_fun <- function(arg_a){return(5 *arg_a)}
test_fun(NULL) # produces NULL, but maybe you prefer an error
test_fun2 <- function(arg_b){assert_no_null_arguments(); return(5 * arg_b)}
test_fun2(NULL) # produces an error rather than NULL
test_fun2() # informs user of _all_ missing arguments rather than only the first missing arg found (base R behavior)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.