[Rd] RFC: is.whole() ? {"how to judge if a variable is an integer"}

Michel Lang lang at statistik.tu-dortmund.de
Thu Oct 30 11:04:41 CET 2014


2014-10-28 10:32 GMT+01:00 Martin Maechler <maechler at stat.math.ethz.ch>:

> Given all this, the r-help and stackoverflow threads,
> maybe we should decide that such an is.whole() function should
> be added to R and maintained (by me for the time), so we do have
> a better place to point people to, and well documented -- and
> eventually "optimized" -- behavior ?
>
> Personally I do think I'd want a "signature" of
>     function (x, tolerance = sqrt(.Machine$double.eps))

I've written some C code which in my opinion would be a good starting
point for an optimized version. The exported function in the checkmate
package is called "isIntegerish" and tests an SEXP to be "safely
convertible" to an INTSXP. You can find it here:
<https://github.com/mllg/checkmate/blob/master/src/is_integerish.c>.

Best,
Michel



More information about the R-devel mailing list