is_wholenumber {ds4psy} | R Documentation |
Test for whole numbers (i.e., integers).
Description
is_wholenumber
tests if x
contains only integer numbers.
Usage
is_wholenumber(x, tol = .Machine$double.eps^0.5)
Arguments
x |
Number(s) to test (required, accepts numeric vectors). |
tol |
Numeric tolerance value.
Default: |
Details
is_wholenumber
does what the base R function is.integer
is not designed to do:
-
is_wholenumber()
returns TRUE or FALSE depending on whether its numeric argumentx
is an integer value (i.e., a "whole" number). -
is.integer()
returns TRUE or FALSE depending on whether its argument is of integer type, and FALSE if its argument is a factor.
See the documentation of is.integer
for definition and details.
See Also
is.integer
function of the R base package.
Other numeric functions:
base2dec()
,
base_digits
,
dec2base()
,
is_equal()
,
num_as_char()
,
num_as_ordinal()
,
num_equal()
Other utility functions:
base2dec()
,
base_digits
,
dec2base()
,
is_equal()
,
is_vect()
,
num_as_char()
,
num_as_ordinal()
,
num_equal()
Examples
is_wholenumber(1) # is TRUE
is_wholenumber(1/2) # is FALSE
x <- seq(1, 2, by = 0.5)
is_wholenumber(x)
# Compare:
is.integer(1+2)
is_wholenumber(1+2)