Check if numbers are natural

Description

Vectorized function for checking if numbers are natural or not. Helps in checking if a vector is of type "order".

Usage

1
is.natural.number(x, tol = .Machine$double.eps^0.5, ...)

Arguments

x

a vector of numbers

tol

tolerence to floating point issues.

...

(not currently in use)

Value

logical - is the entered number natural or not.

Author(s)

Marco Gallotta (a.k.a: marcog), Tal Galili

Source

This function was written by marcog, as an answer to my question here: http://stackoverflow.com/questions/4562257/what-is-the-fastest-way-to-check-if-a-number-is-a-positive-natural-number-in-r

See Also

is.numeric, is.double, is.integer

Examples

1
2
3
4
5
is.natural.number(1) # is TRUE
(x <- seq(-1,5, by=0.5) )
is.natural.number( x )
# is.natural.number( "a" )
all(is.natural.number( x ))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.