run_safely | R Documentation |
This is a wrapper function designed to run a function safely when it is not completely clear what arguments could be passed to the function.
All named arguments in ...
that are not accepted by fun
are removed.
All unnamed arguments are passed on to the function. In case fun
errors,
the error will be converted to a warning and run_safely
returns NULL
.
run_safely
can be useful when constructing functions to be used as
metrics in score()
.
run_safely(..., fun, metric_name)
... |
Arguments to pass to |
fun |
A function to execute. |
metric_name |
A character string with the name of the metric. Used to
provide a more informative warning message in case |
The result of fun
or NULL
if fun
errors
f <- function(x) {x}
scoringutils:::run_safely(2, fun = f, metric_name = "f")
scoringutils:::run_safely(2, y = 3, fun = f, metric_name = "f")
scoringutils:::run_safely(fun = f, metric_name = "f")
scoringutils:::run_safely(y = 3, fun = f, metric_name = "f")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.