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. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel