| arg_data | R Documentation |
Checks whether an argument is an atomic vector (arg_atomic()), a dimensionless atomic vector (arg_vector()), a list (arg_list()), a data frame (arg_data.frame()), a matrix (arg_matrix()), an array (arg_array()), a rectangular data set (arg_data()), or an environment (arg_env()).
arg_atomic(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_vector(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_list(x, df_ok = FALSE, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_data.frame(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_matrix(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_array(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_data(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_env(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
x |
the argument to be checked |
.arg |
the name of the argument supplied to |
.msg |
an optional alternative message to display if an error is thrown instead of the default message. |
.call |
the execution environment of a currently running function, e.g. |
df_ok |
|
Atomic vectors are checked using is.atomic(). Because matrices are considered atomic vectors, arg_vector() additionally checks that there is no "dims" attribute, i.e., that length(dim(x)) == 0L. arg_data() checks whether x is either a data frame or a matrix. arg_list() checks whether x is a list; when df = FALSE, it throws an error when x is a data frame, even though data frames are lists.
Returns NULL invisibly if an error is not thrown.
is.atomic(), is.list(), is.data.frame(), is.matrix(), is.array(), is.environment(), arg_is()
vec <- 1:6
mat <- as.matrix(vec)
dat <- as.data.frame(mat)
lis <- as.list(vec)
nul <- NULL
# arg_atomic
try(arg_atomic(vec))
try(arg_atomic(mat))
try(arg_atomic(dat))
try(arg_atomic(lis))
try(arg_atomic(nul))
# arg_vector
try(arg_vector(vec))
try(arg_vector(mat))
# arg_matrix
try(arg_matrix(vec))
try(arg_matrix(mat))
try(arg_matrix(dat))
# arg_data.frame
try(arg_data.frame(vec))
try(arg_data.frame(mat))
try(arg_data.frame(dat))
# arg_data
try(arg_data(vec))
try(arg_data(mat))
try(arg_data(dat))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.