[R] ifelse behavior
Stephan Holl
sholl at gmx.net
Mon Sep 2 16:34:03 CEST 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dear R-Users,
I cannot understand the behavior of ifelse.
I have a vector blah
> str(blah)
List of 14
$ index.s : num 100
$ index.u : num 100
$ index.t : num 100
$ yabstand.s: num NA
$ yabstand.u: num NA
$ modal.s : int 8
$ modal.u : int 71
$ modal.t : int 21
>
> str(blah$index.s)
num 100
>
everything seems OK.
when I do a ifelse-check, something strange happens:
> ifelse(blah$index.s == 100 ,1,2)
[1] 2
When I replace the blah$index.s with 100 like the following line does
> blah$index.s <- 100
> str(blah$index.s)
num 100
it is a numeric value as well, but the result of the ifelse-check is
different!!
> ifelse(blah$index.s == 100 ,1,2)
[1] 1
that's the result which is correct!
Can anybody explain this behavior please ?!
thank you
- --
- --------------------------------------
Stephan Holl
GnuPG Key-ID: 11946A09
ICQ# 117277975
- --------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9c3bbEg9SKhGUagkRAi3UAJ46mOt/FsDdwzyaZ7vrauarVLpEjgCdHUIp
K6XkXwhVxW65Sw1iiOlk9cE=
=roN2
-----END PGP SIGNATURE-----
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list