[R] is.integer() function

Duncan Murdoch murdoch at stats.uwo.ca
Wed Jan 25 18:36:11 CET 2006


On 1/25/2006 10:57 AM, Barry Rowlingson wrote:
> 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')....

Here "numeric vector" is being used in the R-specific technical sense as 
a vector of double precision values, so the documentor was trying hard 
to be precise.  The problem is that English also admits the 
interpretation in a non-technical sense as a vector of numbers.  I 
believe your country is to blame for the language. :-)

Duncan Murdoch

> 
>   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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list