how to judge a virable is a integer?
It sounds like you want an 'is.integral' function to tell if a number acts like a mathematical integer, as opposed to 'is.integer', which tells if a number is stored as a 32-bit computer integer. The test will depend on what properties of mathematical integers you are most interested in. is.integral <- function (x) (floor(x) == x) & (abs(x) + 1 > abs(x)) will return TRUE if x has no fractional part and the number's putative successor (predecessor if negative) is different than the number. That latter test is equivalent (roughly) to log2(abs(x))<53 and comes into play when you run out of bits in the mantissa of a double precision number. (One might want it to return NA in that case, but I think FALSE works better.) Bill Dunlap TIBCO Software wdunlap tibco.com
On Sat, Oct 18, 2014 at 3:41 AM, PO SU <rhelpmaillist at 163.com> wrote:
Dear usRers, I want to judge virable is or not a integer? e.g. is.integer(1) FALSE because it is a numeric, but i want it's true. as.integer may not be used. because i don't know a is 1 or 1.1. -- PO SU mail: desolator88 at 163.com Majored in Statistics from SJTU
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.