Skip to content

ifelse behavior

5 messages · Stephan Holl, Peter Dalgaard

#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear R-Users,

I cannot understand the behavior of ifelse.
I have a vector 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
num 100
everything seems OK.
when I do a ifelse-check, something strange happens:
[1] 2

When I replace the blah$index.s with 100 like the following line does
num 100
it is a numeric value as well, but the result of the ifelse-check is
different!!
[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:
What happens if you say 

blah$index.s - 100 

in the two cases?
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 02 Sep 2002 16:43:11 +0200 Peter Dalgaard BSA wrote:
Hello Peter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -> whats that ?!
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Stephan Holl <sholl at gmx.net> writes:
I.e.: Never trust exact equality with floatingpoint numbers!
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 02 Sep 2002 17:00:02 +0200 Peter Dalgaard BSA wrote:
Hello Peter
I could solve the problem when I used the round() function. Then the
wanted result came out.

anyway,
thanks for your help

cheers
- -- 
- --------------------------------------
Stephan Holl
GnuPG Key-ID: 11946A09
ICQ# 117277975 
- --------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9c365Eg9SKhGUagkRAvELAJ4pkJLEQMGWBIfswKbvVqBoIvwxOQCbBxRv
vHKRTH9DmRGcc46jGwdxJUQ=
=F4jL
-----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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._