is_positive_integer: Check if a vector has all positive integers

View source: R/predicates.R

is_positive_integerR Documentation

Check if a vector has all positive integers

Description

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

Usage

is_positive_integer(x)

Arguments

x

A vector

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'.

Value

TRUE if all elements are positive integers (NA ignored)

Examples

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

schematic documentation built on June 9, 2025, 5:10 p.m.