Is the input in range?

isInRange(x, lower = -Inf, upper = Inf, closed = c(TRUE, TRUE),
  .xname = getNameInParent(x))

isInClosedRange(x, lower = -Inf, upper = Inf,
  .xname = getNameInParent(x))

isInOpenRange(x, lower = -Inf, upper = Inf,
  .xname = getNameInParent(x))

isInLeftOpenRange(x, lower = -Inf, upper = Inf,
  .xname = getNameInParent(x))

isInRightOpenRange(x, lower = -Inf, upper = Inf,
  .xname = getNameInParent(x))

isNegative(x, .xname = getNameInParent(x))

isPositive(x, .xname = getNameInParent(x))

isNonNegative(x, .xname = getNameInParent(x))

isNonPositive(x, .xname = getNameInParent(x))

isPercentage(x, .xname = getNameInParent(x))

isProportion(x, .xname = getNameInParent(x))

allAreInRange(x, lower = -Inf, upper = Inf, closed = c(TRUE, TRUE),
  .xname = getNameInParent(x))

allAreInClosedRange(x, lower = -Inf, upper = Inf,
  .xname = getNameInParent(x))

allAreInOpenRange(x, lower = -Inf, upper = Inf,
  .xname = getNameInParent(x))

allAreInLeftOpenRange(x, lower = -Inf, upper = Inf,
  .xname = getNameInParent(x))

allAreInRightOpenRange(x, lower = -Inf, upper = Inf,
  .xname = getNameInParent(x))

allAreNegative(x, .xname = getNameInParent(x))

allArePositive(x, .xname = getNameInParent(x))

allAreNonNegative(x, .xname = getNameInParent(x))

allAreNonPositive(x, .xname = getNameInParent(x))

allArePercentage(x, .xname = getNameInParent(x))

allAreProportion(x, .xname = getNameInParent(x))

Arguments

x

Object.

lower

numeric(1). Lower boundary.

upper

numeric(1). Upper boundary.

closed

logical(2). Should the lower (1) and upper (2) bounaries be closed?

.xname

Not intended to be used directly.

Value

TRUE on success; FALSE on failure, with cause attribute set.

Functions

  • isInRange: Vectorized.

  • isInClosedRange: Vectorized.

  • isInOpenRange: Vectorized.

  • isInLeftOpenRange: Vectorized.

  • isInRightOpenRange: Vectorized.

  • isNegative: Vectorized.

  • isPositive: Vectorized.

  • isNonNegative: Vectorized.

  • isNonPositive: Vectorized.

  • isPercentage: Vectorized.

  • isProportion: Vectorized.

  • allAreInRange: Scalar.

  • allAreInClosedRange: Scalar.

  • allAreInOpenRange: Scalar.

  • allAreInLeftOpenRange: Scalar.

  • allAreInRightOpenRange: Scalar.

  • allAreNegative: Scalar.

  • allArePositive: Scalar.

  • allAreNonNegative: Scalar.

  • allAreNonPositive: Scalar.

  • allArePercentage: Scalar.

  • allAreProportion: Scalar.

Intervals

  • Closed: Includes all its limit points, and is denoted with square brackets. For example, [0,1] means greater than or equal to 0 and less than or equal to 1.

  • Open: Does not include its endpoints, and is indicated with parentheses. For example, (0,1) means greater than 0 and less than 1.

See also

Examples

## TRUE ==== isInRange(0, lower = 0, upper = 1)
#> 0 #> TRUE
isInRange(1, lower = 0, upper = 1)
#> 1 #> TRUE
isInClosedRange(1, lower = 0, upper = 1)
#> 1 #> TRUE
isInOpenRange(0.5, lower = 0, upper = 1)
#> 0.5 #> TRUE
isInLeftOpenRange(1, lower = 0, upper = 1)
#> 1 #> TRUE
isInRightOpenRange(0, lower = 0, upper = 1)
#> 0 #> TRUE
isNegative(c(-2, -1))
#> -2 -1 #> TRUE TRUE
isPositive(c(1, 2))
#> 1 2 #> TRUE TRUE
isNonNegative(c(0, 1))
#> 0 1 #> TRUE TRUE
isNonPositive(c(-1, 0))
#> -1 0 #> TRUE TRUE
isPercentage(c(0, 25, 50, 100))
#> 0 25 50 100 #> TRUE TRUE TRUE TRUE
isProportion(c(0, 0.01, 0.1, 1))
#> 0 0.01 0.1 1 #> TRUE TRUE TRUE TRUE
## FALSE ==== isInRange(c(-1, 2), lower = 0, upper = 1)
#> There were 2 failures: #> pos value cause #> 1 1 -1 too low #> 2 2 2 too high
isInClosedRange(c(0, 1), lower = 0, upper = 1)
#> 0 1 #> TRUE TRUE
isInOpenRange(c(1, 2), lower = 0, upper = 1)
#> There were 2 failures: #> pos value cause #> 1 1 1 too high #> 2 2 2 too high
isInLeftOpenRange(0, lower = 0)
#> [1] FALSE #> Cause of failure: #> too low
isInRightOpenRange(1, upper = 1)
#> [1] FALSE #> Cause of failure: #> too high
isPositive(-1)
#> [1] FALSE #> Cause of failure: #> too low
isNegative(1)
#> [1] FALSE #> Cause of failure: #> too high
isPercentage(110)
#> [1] FALSE #> Cause of failure: #> too high
isProportion(1.1)
#> [1] FALSE #> Cause of failure: #> too high