View source: R/stabilize_arg.R
| stabilize_arg | R Documentation |
stabilize_arg() is used by other functions such as stabilize_int(). Use
stabilize_arg() if the type-specific functions will not work for your use
case, but you would still like to check things like size or whether the
argument is NULL.
stabilize_arg_scalar() is optimized to check for length-1 vectors.
stabilize_arg(
x,
...,
allow_null = TRUE,
allow_na = TRUE,
min_size = NULL,
max_size = NULL,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
stabilize_arg_scalar(
x,
...,
allow_null = TRUE,
allow_zero_length = TRUE,
allow_na = TRUE,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
x |
The argument to stabilize. |
... |
Arguments passed to methods. |
allow_null |
|
allow_na |
|
min_size |
|
max_size |
|
x_arg |
|
call |
|
x_class |
|
allow_zero_length |
|
x, unless one of the checks fails.
wrapper <- function(this_arg, ...) {
stabilize_arg(this_arg, ...)
}
wrapper(1)
wrapper(NULL)
wrapper(NA)
try(wrapper(NULL, allow_null = FALSE))
try(wrapper(NA, allow_na = FALSE))
try(wrapper(1, min_size = 2))
try(wrapper(1:10, max_size = 5))
stabilize_arg_scalar("a")
stabilize_arg_scalar(1L)
try(stabilize_arg_scalar(1:10))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.