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

Name of object defined in x. Not intended to be used directly.

Value

TRUE on success; FALSE on failure, with cause 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.

Note

Updated 2019-08-10.

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.000000000000000e+00 #> TRUE
isInRange(1, lower = 0, upper = 1)
#> 1.000000000000000e+00 #> TRUE
isInClosedRange(1, lower = 0, upper = 1)
#> 1.000000000000000e+00 #> TRUE
isInOpenRange(0.5, lower = 0, upper = 1)
#> 5.000000000000000e-01 #> TRUE
isInLeftOpenRange(1, lower = 0, upper = 1)
#> 1.000000000000000e+00 #> TRUE
isInRightOpenRange(0, lower = 0, upper = 1)
#> 0.000000000000000e+00 #> TRUE
isNegative(c(-2, -1))
#> -2.000000000000000e+00 -1.000000000000000e+00 #> TRUE TRUE
isPositive(c(1, 2))
#> 1.000000000000000e+00 2.000000000000000e+00 #> TRUE TRUE
isNonNegative(c(0, 1))
#> 0.000000000000000e+00 1.000000000000000e+00 #> TRUE TRUE
isNonPositive(c(-1, 0))
#> -1.000000000000000e+00 0.000000000000000e+00 #> TRUE TRUE
isPercentage(c(0, 25, 50, 100))
#> 0.000000000000000e+00 2.500000000000000e+01 5.000000000000000e+01 #> TRUE TRUE TRUE #> 1.000000000000000e+02 #> TRUE
isProportion(c(0, 0.01, 0.1, 1))
#> 0.000000000000000e+00 1.000000000000000e-02 1.000000000000000e-01 #> TRUE TRUE TRUE #> 1.000000000000000e+00 #> TRUE
## FALSE ==== isInRange(c(-1, 2), lower = 0, upper = 1)
#> [1] FALSE FALSE #> Cause: 2 failures #> pos value cause #> 1 1 -1.000000000000000e+00 too low #> 2 2 2.000000000000000e+00 too high
isInClosedRange(c(0, 1), lower = 0, upper = 1)
#> 0.000000000000000e+00 1.000000000000000e+00 #> TRUE TRUE
isInOpenRange(c(1, 2), lower = 0, upper = 1)
#> [1] FALSE FALSE #> Cause: 2 failures #> pos value cause #> 1 1 1.000000000000000e+00 too high #> 2 2 2.000000000000000e+00 too high
isInLeftOpenRange(0, lower = 0)
#> [1] FALSE #> Cause: 1 failure #> pos value cause #> 1 1 0.000000000000000e+00 too low
isInRightOpenRange(1, upper = 1)
#> [1] FALSE #> Cause: 1 failure #> pos value cause #> 1 1 1.000000000000000e+00 too high
isPositive(-1)
#> [1] FALSE #> Cause: 1 failure #> pos value cause #> 1 1 -1.000000000000000e+00 too low
isNegative(1)
#> [1] FALSE #> Cause: 1 failure #> pos value cause #> 1 1 1.000000000000000e+00 too high
isPercentage(110)
#> [1] FALSE #> Cause: 1 failure #> pos value cause #> 1 1 1.100000000000000e+02 too high
isProportion(1.1)
#> [1] FALSE #> Cause: 1 failure #> pos value cause #> 1 1 1.100000000000000e+00 too high