Skip to contents

check_odd() and check_is_odd() functions check whether the input is an odd number. The check_odd() function raises an error if the input is not an odd number, while check_is_odd() returns TRUE if the input is an odd number, and FALSE otherwise.

Usage

check_odd(num, par_name = "num")

check_is_odd(num)

Arguments

num

A numeric scalar to check.

par_name

The name of the parameter to display in error messages.

Value

  • check_odd(): Returns the original value of num if it is an odd number. Raises an error message if num is not an odd number.

  • check_is_odd(): Logical value, TRUE if the input is an odd number, and FALSE otherwise.

Examples

# Examples for check_odd()
# ------------------------

check_odd(5)
#> [1] 5

try(check_odd(4))
#> Error in check_odd(4) : Expected 'num' to be an odd number but got 4

# Examples for check_is_odd()
# ---------------------------

check_is_odd(5)
#> [1] TRUE

check_is_odd(4)
#> [1] FALSE