check_iterable()
if the input data is of an acceptable type
(e.g., vector, matrix, data frame, or tibble). Optionally, it can include
character vectors as valid types.
Usage
check_iterable(dat, includes_character = FALSE, par_name = "dat")
check_is_iterable(dat, includes_character = FALSE)
Value
check_iterable()
: Returns the original data if it is one of vector, matrix, data frame, or tibble and raises an error otherwise.check_is_iterable()
: Logical value,TRUE
if the data is iterable, andFALSE
otherwise.
Examples
# Examples for check_iterable()
# -----------------------------
check_iterable(c(1, 2, 3))
#> [1] 1 2 3
check_iterable(data.frame(a = 1))
#> a
#> 1 1
try(check_iterable(5, includes_character = TRUE))
#> Error in check_iterable(5, includes_character = TRUE) :
#> Expected 'dat' to have at least 2 elements but got 1 element
# Examples for check_iterable()
# -----------------------------
check_is_iterable(c(1, 2, 3))
#> [1] TRUE
check_is_iterable(data.frame(a = 1))
#> [1] TRUE
try(check_is_iterable(5, includes_character = TRUE))
#> [1] FALSE