RE: [R] a < b < c is alway TRUE

About this list Date view Thread view Subject view Author view Attachment view

From: Philippe Grosjean (phgrosje@ulb.ac.be)
Date: Fri 06 Jul 2001 - 21:24:38 EST


Message-id: <MABBLJDICACNFOLGIHJOCEFICEAA.phgrosje@ulb.ac.be>


>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@ulb.ac.be or phgrosjean@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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:18 EST