OrderComparisons: Functions to perform simple order comparisons

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

These functions perform simple order comparisons for two arguments, dealing with the machine inaccuracy for floating point arithmetics.

Usage

1
2
3
4
5
6
eq(x, y, tol = .Machine$double.eps^0.5)
ne(x, y, tol = .Machine$double.eps^0.5)
ge(x, y, tol = .Machine$double.eps^0.5)
gt(x, y, tol = .Machine$double.eps^0.5)
le(x, y, tol = .Machine$double.eps^0.5)
lt(x, y, tol = .Machine$double.eps^0.5)

Arguments

x

first argument (must be a numeric scalar)

y

second argument (must be a numeric scalar)

tol

comparison tolerance; differences smaller than tol are not considered.

Details

When comparing two numeric scalars (e.g., for equality), machine inaccuracy can be the source of obviously erroneous results. These functions perform binary order comparisons that are tolerant towards machine inaccuracy, as an alternative to the standard comparators ==, !=, >=, >, <= and <.

Value

The functions return a logical TRUE if their condition holds, and a logical FALSE otherwise.

eq(x, y) checks whether x is equal to y

ne(x, y) checks whether x is not equal to y

ge(x, y) checks whether x is greater than or equal to y

gt(x, y) checks whether x is greater than y

le(x, y) checks whether x is less than or equal to y

lt(x, y) checks whether x is less than y

Note

These functions cannot be used in a vectorized fashion.

Author(s)

Marc Vandemeulebroecke

See Also

identical, all.equal

Examples

1
2
3
  v <- seq(0.7, 0.8, by=0.1)
  v[2]==0.8
  eq(v[2], 0.8)


Search within the adaptTest package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.