Learn R Programming

assertive (version 0.2-6)

assert_has_all_attributes: Does the input have the specified attributes?

Description

Checks to see if the input has the specifed attributes.

Usage

assert_has_all_attributes(x, attrs)

assert_has_any_attributes(x, attrs)

has_attributes(x, attrs, .xname = get_name_in_parent(x))

Arguments

x
Input to check.
attrs
Desired attributes.
.xname
Not intended to be used directly.

Value

  • has_attributes returns TRUE where x has the attributes specified in attrs. assert_has_terms returns nothing but throws an error if has_terms is not TRUE.

Examples

Run this code
x <- structure(c(a = 1), b = 2)
assert_has_all_attributes(x, c("names", "b"))
assert_has_any_attributes(x, c("names", "c"))
#These examples should fail.
dont_stop(assert_has_all_attributes(x, c("names", "c")))

Run the code above in your browser using DataLab