Check that value x is positive

assert_pos(
  x,
  zero_allowed = TRUE,
  message1 = "%s must be greater than or equal to zero",
  message2 = "%s must be greater than zero",
  name = deparse(substitute(x))
)

Arguments

x

Value to check if positive

zero_allowed

Indicator (TRUE/FALSE) of whether zero is allowed

message1

Message to output if x is negative (when zero allowed)

message2

Message to output if x is not positive (when zero disallowed)

name

Name

Details

Check that x is positive (zero allowed or disallowed using zero_allowed parameter)