Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

is_float

Check if a variable is of (non-integer) double type or a whole number


Description

is_float() checks whether an input vector or value is a numeric non-integer (double), depending on fractional parts of the value(s). is_whole() does the opposite and checks whether an input vector is a whole number (without fractional parts).

Usage

is_float(x)

is_whole(x)

Arguments

x

A value, vector or data frame.

Value

For is_float(), TRUE if x is a floating value (non-integer double), FALSE otherwise (also returns FALSE for character vectors and factors). For is_whole(), TRUE if x is a vector with whole numbers only, FALSE otherwise (returns TRUE for character vectors and factors).

Examples

data(mtcars)
data(iris)

is.double(4)
is_float(4)
is_float(4.2)
is_float(iris)

is_whole(4)
is_whole(4.2)
is_whole(mtcars)

sjmisc

Data and Variable Transformation Functions

v2.8.6
GPL-3
Authors
Daniel Lüdecke [aut, cre] (<https://orcid.org/0000-0002-8895-3206>), Iago Giné-Vázquez [ctb], Alexander Bartel [ctb] (<https://orcid.org/0000-0002-1280-6138>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.