Learn R Programming

litteR (version 1.0.0)

is_natural_number: 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)

Value

TRUE in case x is a natural number,

FALSE otherwise.

Arguments

x

numeric vector

Examples

Run this code
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)

Run the code above in your browser using DataLab