obj_is_list | R Documentation |
obj_is_list()
tests if x
is considered a list in the vctrs sense. It
returns TRUE
if:
x
is a bare list with no class.
x
is a list explicitly inheriting from "list"
.
list_all_vectors()
takes a list and returns TRUE
if all elements of
that list are vectors.
list_all_size()
takes a list and returns TRUE
if all elements of that
list have the same size
.
obj_check_list()
, list_check_all_vectors()
, and list_check_all_size()
use the above functions, but throw a standardized and informative error if
they return FALSE
.
obj_is_list(x)
obj_check_list(x, ..., arg = caller_arg(x), call = caller_env())
list_all_vectors(x)
list_check_all_vectors(x, ..., arg = caller_arg(x), call = caller_env())
list_all_size(x, size)
list_check_all_size(x, size, ..., arg = caller_arg(x), call = caller_env())
x |
For |
... |
These dots are for future extensions and must be empty. |
arg |
An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem. |
call |
The execution environment of a currently
running function, e.g. |
size |
The size to check each element for. |
Notably, data frames and S3 record style classes like POSIXlt are not considered lists.
list_sizes()
obj_is_list(list())
obj_is_list(list_of(1))
obj_is_list(data.frame())
list_all_vectors(list(1, mtcars))
list_all_vectors(list(1, environment()))
list_all_size(list(1:2, 2:3), 2)
list_all_size(list(1:2, 2:4), 2)
# `list_`-prefixed functions assume a list:
try(list_all_vectors(environment()))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.