is_natural_number {litteR} | R Documentation |
Test for natural numbers according to ISO 80000-2, that is the set 0, 1, 2, ...
is_natural_number(x)
x |
|
TRUE
in case x
is a natural number,
FALSE
otherwise.
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)