[R] Basic question on function "identical"

Thomas Lumley tlumley at u.washington.edu
Fri Dec 12 23:54:51 CET 2003


On Fri, 12 Dec 2003, John Welsh wrote:

>
>
> > for(i in c(1:5))
> + {
> + print(identical(i,1))
> + }
>
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
>
> Why don't I get:
>
> [1] TRUE
> [1] FALSE
> [1] FALSE
> [1] FALSE
> [1] FALSE
>

Because the first element of 1:5 is an integer and 1 is a real number.
all.equal() will be TRUE, and == will probably be TRUE>

	-thomas




More information about the R-help mailing list