[R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Sep 15 18:22:03 CEST 2009



Corrado wrote:
> Dear R,
> 
> the condition: 
> 
> identical(length(x),1) returns FALSE 
> 
> but
> 
> print(length(x))
> 
> returns 1 and:
> 
> is.vector(x) is TRUE.
> is.integer(length(x)) is TRUE
> length(x) ==1 is TRUE
> 
> I am puzzled.
> 
> Regards


 > is.integer(length(x))
[1] TRUE
 > is.integer(1)
[1] FALSE


Hence:
 > identical(length(x), 1L)
[1] TRUE


Uwe Ligges




More information about the R-help mailing list