Vectorized function for checking if numbers are natural or not. Helps in checking if a vector is of type "order".
is.natural.number(x, tol = .Machine$double.eps^0.5, ...)
This function was written by marcog, as an answer to my question here: https://stackoverflow.com/questions/4562257/what-is-the-fastest-way-to-check-if-a-number-is-a-positive-natural-number-in-r
logical - is the entered number natural or not.
is.natural.number(1) # is TRUE
#> [1] TRUE
(x <- seq(-1, 5, by = 0.5))
#> [1] -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
is.natural.number(x)
#> [1] FALSE FALSE FALSE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE
#> [13] TRUE
# is.natural.number( "a" )
all(is.natural.number(x))
#> [1] FALSE