Learn R Programming

chk (version 0.4.0)

chk_whole_number: Check Whole Number

Description

Checks if non-missing integer scalar or double equivalent using

vld_number(x) && (is.integer(x) || vld_true(all.equal(x, trunc(x))))

Pass: 1, 2L, 1e10, -Inf

Fail: "a", 1:3, NA_integer_, log(10)

Usage

chk_whole_number(x, x_name = NULL)

vld_whole_number(x)

Arguments

x

The object to check.

x_name

A string of the name of object x or NULL.

Value

The chk_ function throws an informative error if the test fails.

The vld_ function returns a flag indicating whether the test was met.

Functions

  • vld_whole_number: Validate Whole Number

See Also

Other chk_scalars: chk_datetime(), chk_date(), chk_number(), chk_scalar(), chk_string(), chk_tz()

Examples

Run this code
# NOT RUN {
# chk_whole_number
chk_whole_number(2)
try(chk_whole_number(1.1))
# vld_whole_number
vld_whole_number(2)
# }

Run the code above in your browser using DataLab