Learn R Programming

tractor.base (version 1.1.0)

equivalent: Test two numeric vectors for equivalence

Description

Test two numeric vectors for equivalence.

Usage

equivalent(x, y, signMatters = TRUE, ...)

Arguments

x
The first numeric vector.
y
The second numeric vector.
signMatters
Logical value: if FALSE then equivalence in absolute value is sufficient.
...
Additional arguments to all.equal, notably tolerance.

Value

  • TRUE if all elements of x match all elements of y to within tolerance, ignoring signs if required. FALSE otherwise.

Details

This function is a wrapper for isTRUE(all.equal(x,y,...)), but with the additional capability of doing sign-insensitive comparison.

See Also

all.equal

Examples

Run this code
equivalent(c(-1,1), c(1,1))  # FALSE
equivalent(c(-1,1), c(1,1), signMatters=FALSE)  # TRUE
equivalent(1:2, 2:3, tolerance=2)  # TRUE

Run the code above in your browser using DataLab