is_whole_number: Check if a vector has all whole numbers

View source: R/predicates.R

is_whole_numberR Documentation

Check if a vector has all whole numbers

Description

Similar to 'is_positive_integer()' but without the constraint that the underlying data type is actually integer. Useful if the numbers are stored as 'numeric' but you want to check that they are whole.

Usage

is_whole_number(x)

Arguments

x

A vector

Details

'NA's are ignored.

Value

TRUE if all elements are whole numbers (NA ignored)

Examples

is_whole_number(c(2.0, 4.0)) # TRUE
is_whole_number(c(-1.4)) # FALSE

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