R/is_float.R
is_float.Rd
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).
is_float(x) is_whole(x)
x | A value, vector or data frame. |
---|
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).
data(mtcars) data(iris) is.double(4)#> [1] TRUEis_float(4)#> [1] FALSEis_float(4.2)#> [1] TRUEis_float(iris)#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> TRUE TRUE TRUE TRUE FALSEis_whole(4)#> [1] TRUEis_whole(4.2)#> [1] FALSEis_whole(mtcars)#> mpg cyl disp hp drat wt qsec vs am gear carb #> FALSE TRUE FALSE TRUE FALSE FALSE FALSE TRUE TRUE TRUE TRUE