[R] is.integer() function

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Wed Jan 25 16:57:20 CET 2006


Gabor Csardi wrote:
> Becaues is.integer shows the internal representation, which is not an
> integer but a double (real number). Some functions create integer vectors,

  Some functions that you might think create integer vectors and even 
seem to say they create integer vectors dont create integer vectors:

      'ceiling' takes a single numeric argument 'x' and returns a
      numeric vector containing the smallest integers not less than the
      corresponding elements of 'x'.

 > ceiling(0.5)
[1] 1

 > is.integer(ceiling(0.5))
[1] FALSE

 > is.integer(1:3)
[1] TRUE
 > is.integer(ceiling(1:3))
[1] FALSE


  This could possibly be a documentation problem, since ?ceiling is 
using 'integer' in the sense of 'whole number', whereas ?is.integer is 
concerned with internal representation (aka 'storage mode')....

  This seems to be an endless source of confusion to anyone who didn't 
start their programming days in Fortran, C, or assembly language (or 
other strongly-typed language, I guess).

Barry




More information about the R-help mailing list