try2int: Attempt coercion to integer

Description Usage Arguments Author(s) Source

View source: R/utility_functions.R

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

1
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 1 + .Machine$double.eps^0.49 is not.

Author(s)

James Arnold

Source

Stackoverflow thread


popEpi documentation built on May 19, 2017, 8:48 p.m.

Search within the popEpi package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.