is_equal_to: How does the input relate to a value?

Description Usage Arguments Value Note Examples

Description

Is x equal/not equal/greater than/less than y?

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
assert_all_are_equal_to(x, y, tol = 100 * .Machine$double.eps,
  na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

assert_any_are_equal_to(x, y, tol = 100 * .Machine$double.eps,
  na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

assert_all_are_not_equal_to(x, y, tol = 100 * .Machine$double.eps,
  na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

assert_any_are_not_equal_to(x, y, tol = 100 * .Machine$double.eps,
  na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

assert_all_are_greater_than(x, y, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_greater_than(x, y, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_all_are_greater_than_or_equal_to(x, y, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_greater_than_or_equal_to(x, y, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_all_are_less_than(x, y, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_less_than(x, y, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_all_are_less_than_or_equal_to(x, y, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_less_than_or_equal_to(x, y, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

is_equal_to(x, y, tol = 100 * .Machine$double.eps,
  .xname = get_name_in_parent(x), .yname = get_name_in_parent(x))

is_not_equal_to(x, y, tol = 100 * .Machine$double.eps,
  .xname = get_name_in_parent(x), .yname = get_name_in_parent(x))

is_greater_than(x, y, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(x))

is_greater_than_or_equal_to(x, y, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(x))

is_less_than(x, y, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(x))

is_less_than_or_equal_to(x, y, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(x))

Arguments

x

A numeric vector.

y

Another numeric vector, typically scalar or the same length as x. See note.

tol

Values within tol are considered equal.

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

.xname

Not intended to be used directly.

.yname

Not intended to be used directly.

Value

TRUE if the input x is equal/not equal/greater than/less than y

Note

The usual recycling rules apply when x and y are different lengths. See Intro to R for details: https://cran.r-project.org/doc/manuals/r-devel/R-intro.html#Vector-arithmetic https://cran.r-project.org/doc/manuals/r-devel/R-intro.html#The-recycling-rule

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Approximate and exact floating point comparisons:
# See FAQ on R 7.31
x <- sqrt(2) * sqrt(2)
is_equal_to(x, 2)
is_equal_to(x, 2, tol = 0)
is_not_equal_to(x, 2)
is_not_equal_to(x, 2, tol = 0)

# Elements of x and y are recycled
is_equal_to(1:6, 1:3)

# Inequalities
x <- c(1 - .Machine$double.neg.eps, 1, 1 + .Machine$double.eps)
is_greater_than(x, 1)
is_greater_than_or_equal_to(x, 1)
is_less_than(x, 1)
is_less_than_or_equal_to(x, 1)

assertive.numbers documentation built on May 2, 2019, 3:30 p.m.