From savicky at cs.cas.cz  Thu Apr 23 12:49:01 2009
From: savicky at cs.cas.cz (Petr Savicky)
Date: Thu, 23 Apr 2009 12:49:01 +0200
Subject: [Rd] 'is.integer' (PR#13671)
In-Reply-To: <18928.14049.374028.202617@lynne.math.ethz.ch>
References: <20090422174516.2EB1928321BF@mail.pubhealth.ku.dk>
	<49EF7FF1.704@acm.org>
	<18928.14049.374028.202617@lynne.math.ethz.ch>
Message-ID: <20090423104901.GB13115@cs.cas.cz>

On Thu, Apr 23, 2009 at 11:37:37AM +0200, Martin Maechler wrote:
[snip]
>     TP> To test whether a value is an integer value, you can so something like this:
> 
>     >> is.wholenumber <- function(x, tolerance = .Machine$double.eps^0.5) 
>     TP> return(abs(x - round(x)) < tolerance)
>     >> is.wholenumber(1)
>     TP> [1] TRUE
>     >> is.wholenumber(seq(1,5,by=0.5))
>     TP> [1]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE
>     >> 
> 
> Thank you, Tony.
> 
> Somewhat contrary to our (R-core) beliefs that a reference
> should be concise and correct, I have now added (an abridged
> version of) the is.wholenumber() function to the *examples* 
> on the  help(is.integer)  page and a note too.
> 
> Let's pretend we hope that this will stop such bug reports 
> ;-)

Besides the current bug report caused by misunderstanding of the
difference between a value and a data type, there are also discussions
concerning rounding errors of decimal numbers. These are, unfortunately,
quite frequent. If i can make a suggestion in order to (at least try to)
minimize also such discussions, may be it could help, if the contents of FAQ,
which is at the top of the FAQ page, contains the word accuracy. The path
to FAQ 7.31 discussing this topic goes through titles of sections
  R Miscellanea
and
  Why doesn't R think these numbers are equal? 

May be, if the name of "R Miscellanea" is more specific and contains the
word "accuracy" or if there is a section specifically for accuracy
issues, people would find the information in FAQ 7.31 more easily.

Petr.



[Rd] 'is.integer' (PR#13671)
Petr Savicky