Learn R Programming

pretestcad (version 1.1.0)

check_if_integer: Check If Integer

Description

Check if the input variable is an integer

Usage

check_if_integer(
  x,
  allow_na = TRUE,
  arg = rlang::caller_arg(x),
  error_call = rlang::caller_env()
)

Value

The variable itself or an error message if variable is not non-negative

Arguments

x

Input variable to check if it is an integer

allow_na

Input boolean to determine if NA or NaN is allowed. Default: TRUE

arg

An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.

error_call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

See Also

Examples

Run this code
# No error
input = 0
try(check_if_integer(input))

# Error as 5.5 is not an integer
input = 5.5
try(check_if_integer(input))

Run the code above in your browser using DataLab