[R] a < b < c is alway TRUE
Philippe Grosjean
phgrosje at ulb.ac.be
Fri Jul 6 13:24:38 CEST 2001
>One of our students did something like:
> x[a < b < c]
>instead of
> x[a < b & b < c]
>But why is
> 3 < 2 < 1 # [1] TRUE ???
>Is there any reason?
>Or wouldn't it be better to get a warning / error?
>Uwe Ligges
The answer is simple: the first inequation 3 < 2 is solved, which gives
FALSE. Then the second inequation to be solved is: FALSE < 1. Since
as.numeric(FALSE) is 0, you have to solve 0 < 1, which is... TRUE. Hence,
this is not a bug, but an incorrect use of the R language.
Best regards,
Philippe Grosjean
...........]<(({?<...............<?}))><...............................
) ) ) ) ) __ __
( ( ( ( ( |__) | _
) ) ) ) ) | hilippe |__)rosjean
( ( ( ( ( Marine Biol. Lab., ULB, Belgium
) ) ) ) ) __
( ( ( ( ( |\ /| |__)
) ) ) ) ) | \/ |ariculture & |__)iostatistics
( ( ( ( (
) ) ) ) ) e-mail: phgrosje at ulb.ac.be or phgrosjean at sciviews.org
( ( ( ( ( SciViews project coordinator (http://www.sciviews.org)
) ) ) ) ) tel: 00-32-2-650.29.70 (lab), 00-32-2-673.31.33 (home)
( ( ( ( (
) ) ) ) ) "I'm 100% confident that p is between 0 and 1"
( ( ( ( ( L. Gonick & W. Smith (1993)
) ) ) ) )
.......................................................................
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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