-----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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Stephan Holl <sholl at gmx.net> writes:> > 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 ?!What happens if you say blah$index.s - 100 in the two cases? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 At 02 Sep 2002 16:43:11 +0200 Peter Dalgaard BSA wrote: Hello Peter> Stephan Holl <sholl at gmx.net> writes:^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -> whats that ?!> > Can anybody explain this behavior please ?! > > What happens if you say > > blah$index.s - 100 > > in the two cases?blah$index.s -100 [1] -1.421085e-14 cheers - -- - -------------------------------------- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 - -------------------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9c3n9Eg9SKhGUagkRAidAAJwJbsISZ+D6V4ZnuN6rhTv7QYwvBwCeM5NL PHZOC+C7+hA7gv6cwYCXPvI=m8Qn -----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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._