Skip to contents

A positive integer is a whole number that is greater than 0.

Usage

is_positive_integer(x)

Arguments

x

A vector

Value

TRUE if all elements are positive integers (NA ignored)

Details

This check requires `is.integer(x)` to be true. If you want a more flexible check that allows for numbers of type `numeric` but still want them to be integers, then use `is_whole_number()`.

`NA`s are ignored as long as they are `NA_integer`.

Examples

is_positive_integer(c(1L, 2L, 4L)) # TRUE
#> [1] TRUE
is_positive_integer(2.4) # FALSE
#> [1] FALSE
is_positive_integer(-3) # FALSE
#> [1] FALSE