Skip to contents

Checks if an argument is an atomic vector

Usage

assert_atomic_vector(arg, optional = FALSE)

Arguments

arg

A function argument to be checked

optional

Is the checked argument optional? If set to FALSE and arg is NULL then an error is thrown

Value

The function throws an error if arg is not an atomic vector. Otherwise, the input is returned invisibly.

Examples

example_fun <- function(x) {
  assert_atomic_vector(x)
}

example_fun(1:10)

try(example_fun(list(1, 2)))
#> Error in assert_atomic_vector(x) : 
#>   `x` must be an atomic vector but is a list