is_natural_number: Test for Natural Numbers

View source: R/utils.R

is_natural_numberR Documentation

Test for Natural Numbers

Description

Test for natural numbers according to ISO 80000-2, that is the set 0, 1, 2, ...

Usage

is_natural_number(x)

Arguments

x

numeric vector

Value

TRUE in case x is a natural number, FALSE otherwise.

Examples

stopifnot(!is_natural_number(3.1))
stopifnot(!is_natural_number(2.99))
stopifnot(is_natural_number(3))
stopifnot(all(is_natural_number(0:9)))
stopifnot(sum(is_natural_number(c(1, 2.5, 3))) == 2)


litteR documentation built on Aug. 27, 2022, 1:05 a.m.