Learn R Programming

popEpi (version 0.3.0)

try2int: Attempt coercion to integer

Description

Attempts to convert a numeric object to integer, but won't if loss of information is imminent (if values after decimal are not zero for even one value in obj)

Usage

try2int(obj, tol = .Machine$double.eps^0.5)

Arguments

obj
a numeric vector
tol
tolerance; if each numeric value in obj deviate from the corresponding integers at most the value of tol, they are considered to be integers; e.g. by default 1 + .Machine$double.eps is considered to be an integer but

source

http://stackoverflow.com/questions/3476782/how-to-check-if-the-number-is-integer{Stackoverflow thread}