Assertions to Check Properties of Variables

A set of predicates and assertions for checking the properties of variables, such as length, names and attributes. This is mainly for use by other package developers who want to include run-time testing features in their own packages. End-users will usually want to use assertive directly.

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Is the package on CRAN? SemaphoreCI Build Status AppVeyor Build Status

A set of predicates and assertions for checking the properties of variables, such as length, names and attributes. Most of the documentation is on the assertive page. End-users will usually want to use assertive directly.


To install the stable version, type:


To install the development version, you first need the devtools package.


Then you can install the package using



has_attributes checks a variable for the presence of named attributes. has_any_attributes and has_no_attributes check for the presence or absence of any attributes at all.

has_dims, has_rows, and has_cols check for the dimensions, rows and columns respectively.

has_duplicates and has_no_duplicates check whether or not a vector has duplicate elements.

has_names, has_dimnames, has_rownames, and has_colnames check for various types of name.

is_atomic, is_recursive, and is_vector check for these types of variables.

is_empty, is_non_empty, is_scalar, and is_non_scalar check for objects of length 0 or 1 (or objects with 0/1 element).

is_of_length, has_elements, and is_of_dimension provide more general variable size checks.

are_same_length and have_same_dims check for two variables having the same length/dimensions.

is_null and is_not_null check whether an object is NULL or not.

is_unsorted checks for unsorted vectors.


Predicates that return a vector have two corresponding assertions. For example, has_attributes has assert_has_all_attributes and assert_has_any_attributes.

Predicates returning a single logical value have one corresponding assertion. For example, is_null has assert_is_null.


DIM returns the dimension of an object, and works with vectors (like NROW and NCOL).

n_elements returns the number of elements in an object.


0.0-4 Better err msg, examples, tests for is_null. Better documentation and examples is *_attributes fns. 0.0-3 Added is_monotonic_increasing/is_monotonic_decreasing. 0.0-2 Added is_nested/is_non_nested. Added has_slot. Reexported assert_all/any_are_same_length. 0.0-1 Content extracted from assertive 0.3-0, and tidied.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.0-4 by Richard Cotton, 5 years ago

Report a bug at

Browse source code at

Authors: Richard Cotton [aut, cre]

Documentation:   PDF Manual  

GPL (>= 3) license

Imports assertive.base, methods

Suggests testthat

Imported by assertive, assertive.code, assertive.types, flippant, multipanelfigure, poio, tensorr.

See at CRAN