is_array: Is the input an array or matrix?

Description Usage Arguments Value Examples

View source: R/is-type-base.R

Description

Checks to see if the input is an array or matrix.

Usage

1
2
3
4
5
6
7
assert_is_array(x, severity = getOption("assertive.severity", "stop"))

assert_is_matrix(x, severity = getOption("assertive.severity", "stop"))

is_array(x, .xname = get_name_in_parent(x))

is_matrix(x, .xname = get_name_in_parent(x))

Arguments

x

Input to check.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

.xname

Not intended to be used directly.

Value

is_array and is_matrix wrap is.array, and is.matrix respectively, providing more information on failure. The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

Examples

1
2
3
4
5
assert_is_array(array())
assert_is_array(matrix())
assert_is_matrix(matrix())
#These examples should fail.
assertive.base::dont_stop(assert_is_matrix(array()))

Example output

$`assert_is_matrix(array())`
<assertionError: is_matrix : array() is not of class 'matrix'; it has class 'logical array'.>

assertive.types documentation built on May 1, 2019, 10:31 p.m.