From lang at statistik.tu-dortmund.de  Thu Oct 30 11:04:41 2014
From: lang at statistik.tu-dortmund.de (Michel Lang)
Date: Thu, 30 Oct 2014 11:04:41 +0100
Subject: [Rd] RFC: is.whole() ? {"how to judge if a variable is an
	integer"}
In-Reply-To: <21583.25274.770806.923857@stat.math.ethz.ch>
References: <690d9165.1afb1.14922d8a014.Coremail.rhelpmaillist@163.com>
	<A38E19EC-B6B9-48A2-8104-EFBD8155FC9F@xs4all.nl>
	<25838d30.14585.14922fdd93b.Coremail.rhelpmaillist@163.com>
	<0301C365-5456-429A-A8FB-5D1CE2746342@LGCGroup.com>
	<13dbd627.1c610.14923a61cbe.Coremail.rhelpmaillist@163.com>
	<CAJRuHoqqfLpgeZK8VyfuxZE1UM8F2nh2ucYiH7BZc09GFat6Rw@mail.gmail.com>
	<8f0756d.11.1492435a673.Coremail.rhelpmaillist@163.com>
	<CAF8bMcaAnGvZiTrrmMMnFX2Oe4iExCM8VxqqUOoHN6uGY44Xew@mail.gmail.com>
	<21583.25274.770806.923857@stat.math.ethz.ch>
Message-ID: <CAF6EP_4S+9KPzUaUBhsLz0FkFzsX3MboPw_-MTS+DO7qhL8dxA@mail.gmail.com>

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



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