Learn R Programming

crmPack (version 2.0.0)

check_equal: Check if All Arguments Are Equal

Description

[Experimental] Elements of ... must be numeric vectors or scalars.

This function performs an element-by-element comparison of the first object provided in ... with every other object in ... and returns TRUE if all comparisons are equal within a given tolerance and FALSE otherwise.

[Experimental] Elements of ... must be numeric vectors or scalars.

This function performs an element-by-element comparison of the first object provided in ... with every other object in ... and throws an error if they are not.

Usage

check_equal(..., tol = sqrt(.Machine$double.eps))

assert_equal( ..., tol = sqrt(.Machine$double.eps), .var.name = vname(x), add = NULL )

Value

TRUE if all element-by-element differences are less than tolerance

in magnitude, FALSE otherwise.

list(...), invisibly.

Arguments

...

(numeric)
vectors to be compared

tol

(numeric)
the maximum difference to be tolerated when judging equality

.var.name

[character(1)]
Name of the checked object to print in assertions. Defaults to the heuristic implemented in vname.

add

[AssertCollection]
Collection to store assertion messages. See AssertCollection.

See Also

assertions for more details.

assertions for more details.

Examples

Run this code
check_equal(1:2, 1:2) # TRUE
check_equal(1:2, 2:3) # "Not all equal"
check_equal(Inf, Inf) # "Not all equal"
check_equal(0.01, 0.02) # "Not all equal"
check_equal(0.01, 0.02, tol = 0.05) # TRUE
check_equal(1, c(1, 1)) # "Not all equal"
assert_equal(1:2, 1:2) # no error
assert_equal(0.01, 0.02, tol = 0.05) # no error

Run the code above in your browser using DataLab