[R] integers

(Ted Harding) Ted.Harding at manchester.ac.uk
Tue Sep 4 12:11:49 CEST 2007


On 04-Sep-07 09:53:43, Christoph Heibl wrote:
> Hi list,
> 
> The function is.integer tests if an object is of type integer:
> 
> see e.g.:
> 
> is.integer(12)        # FALSE
> is.real(12)   # TRUE
> mode(12)              # "numeric"
> 
> But how can I test if a number is actually an integer? R seek is  
> difficult to search in this case because it mainly yields entries  
> about the integer()-function family.
> 
> Thanks for any hint!
> Christoph Heibl

In infer you want to test whether the real x has an integer value.

((x-floor(x))==0)

would do it (covers negative integers as well), though there may
well be a smarter way.

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 04-Sep-07                                       Time: 11:11:46
------------------------------ XFMail ------------------------------



More information about the R-help mailing list