[R] integers

Martin Maechler maechler at stat.math.ethz.ch
Tue Sep 4 12:33:15 CEST 2007


>>>>> "CH" == Christoph Heibl <christoph.heibl at gmx.net>
>>>>>     on Tue, 4 Sep 2007 11:53:43 +0200 writes:

    CH> Hi list,
    CH> The function is.integer tests if an object is of type integer:

    CH> see e.g.:

    CH> is.integer(12)	# FALSE
    CH> is.real(12)	# TRUE
    CH> mode(12)		# "numeric"

    CH> But how can I test if a number is actually an integer? 

something like        	      round(x) == x
is often good enough, maybe   x %% 1 == 0
seems a bit more efficient.

Note that both return  NA  whenever  x[] is NA so may not directly be
appropriate for your use case.


    CH> R seek is  difficult to search in this case because it mainly yields entries  
    CH> about the integer()-function family.

"R seek" ???

Do you mean the R function  RSiteSearch() which goes to
'http://search.r-project.org/' ?

Well,  calling  
  RSiteSearch("integer number")

gives almost 3000 hits, *but* number 10 is exactly relevant to
your question...

    CH> Thanks for any hint!
    CH> Christoph Heibl



More information about the R-help mailing list