check_expr | R Documentation |
This functions checks the evaluation of an expression and, if an error is thrown, captures it and integrates the captured message after a custom error message.
check_expr(expr, ..., clean, up = 0, arg_name, verbatim = FALSE)
check_expr_hook(expr, ..., clean, arg_name, verbatim = FALSE)
generate_check_expr_hook(namespace)
expr |
An expression to be evaluated. |
... |
Character scalars. The values of If argument |
clean |
Character vector, default is missing. If provided, the function
|
up |
Integer, default is 0. It is used to construct the call in the error message.
By default the call reported is the function containing |
arg_name |
Character scalar, default is missing. Used when the expression in
|
verbatim |
Logical scalar, default is |
namespace |
Character scalar giving the namespace for which the hooks are valid. Only useful when hook functions are used in a package. |
The purpose of this functions is to provide useful error messages to the user.
check_expr_hook()
: As check_expr
but sets the error call at the level of the hooked function
generate_check_expr_hook()
: Generates a package specific check_expr_hook
function
Laurent Berge
For general argument checking, see check_arg()
and check_set_arg()
.
test = function(x, y){
check_expr(mean(x, y), "Computing the mean didn't work:")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.