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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Uwe Ligges writes: > 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 ??? > 3 < 2 < 1 seems to be seen like a double no because 3 < 2 < 1 < 0 returns F. It looks like the multiplication of -1 what is strange, because F corresponds to the value 0. So if you do (3<2)*(2<1) you get 0 and not the value of T (=1). -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Monika Ferster wrote:> > Uwe Ligges writes: > > 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 ??? > >3 < 2 is FALSE=0, and 0<1 is always TRUE.> > 3 < 2 < 1 seems to be seen like a double no because 3 < 2 < 1 < 0 returns > F. It looks like the multiplication of -1 what is strange, because F > corresponds to the value 0. So if you do (3<2)*(2<1) you get 0 and not the > value of T (=1). > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Mag. David Meyer Wiedner Hauptstrasse 8-10 Vienna University of Technology A-1040 Vienna/AUSTRIA Department for Statistics, Probability Tel.: (+431) 58801/10772 Theory and Actuarial Mathematics mail: david.meyer at ci.tuwien.ac.at -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 3 < 2[1] FALSE> F < 1[1] TRUE> as.numeric(F)[1] 0 p. On Fri, Jul 06, 2001 at 12:08:51PM +0200, Monika Ferster wrote:> Uwe Ligges writes: > > 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 ??? > > > > 3 < 2 < 1 seems to be seen like a double no because 3 < 2 < 1 < 0 returns > F. It looks like the multiplication of -1 what is strange, because F > corresponds to the value 0. So if you do (3<2)*(2<1) you get 0 and not the > value of T (=1). > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- P.Malewski, Limmerstr.47, 30451 Hannover, 0511-2135008 At work: http://www.MH-Hannover.de 0511 532 3194 / Fax: 0511 532 3190, P.Malewski at tu-bs.de, peter.malewski at gmx.de, malewski.peter at mh-hannover.de. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I forgot the explanation: R (and s+3) evalutes from left to right and converts logical to numeric. see below. On Fri, Jul 06, 2001 at 12:48:01PM +0200, Peter Malewski wrote:> > > 3 < 2 > [1] FALSE > > F < 1 > [1] TRUE > > as.numeric(F) > [1] 0 > > > p. > > > On Fri, Jul 06, 2001 at 12:08:51PM +0200, Monika Ferster wrote: > > Uwe Ligges writes: > > > 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 ??? > > > > > > > 3 < 2 < 1 seems to be seen like a double no because 3 < 2 < 1 < 0 returns > > F. It looks like the multiplication of -1 what is strange, because F > > corresponds to the value 0. So if you do (3<2)*(2<1) you get 0 and not the > > value of T (=1). > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > > 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 > > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ > > -- > P.Malewski, Limmerstr.47, 30451 Hannover, 0511-2135008 > At work: http://www.MH-Hannover.de 0511 532 3194 / Fax: 0511 532 3190, > P.Malewski at tu-bs.de, peter.malewski at gmx.de, malewski.peter at mh-hannover.de.-- P.Malewski, Limmerstr.47, 30451 Hannover, 0511-2135008 At work: http://www.MH-Hannover.de 0511 532 3194 / Fax: 0511 532 3190, P.Malewski at tu-bs.de, peter.malewski at gmx.de, malewski.peter at mh-hannover.de. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 3 < 2 < 1 # [1] TRUE ???this is evaluated from left to right: (3<2)<1 3<2 = FALSE FALSE<1 = TRUE what's surprising is the following:> FALSE<1[1] TRUE> FALSE>1[1] FALSE> TRUE<1[1] FALSE> TRUE>1[1] FALSE because of symmetry i'd expect TRUE>1 to be TRUE. cu till -- "I have seen things you people wouldn't believe. Attack-ships on fire off the shoulder of Orion. I watched seabeams glitter in the dark near the Tannhauser gate. All those moments will be lost in time like tears in rain. Time to die." (Roy) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>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 LiggesThe 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 3 < 2 < 1 seems to be seen like a double no because 3 < 2 < 1 < 0 returns > F.evaluation from left to right: 3 < 2 < 1 < 0 reads like ((3<2)<1)<0 evaluates to ( FALSE < 1) < 0 evaluates to TRUE < 0 evaluates to FALSE cu till -- "I have seen things you people wouldn't believe. Attack-ships on fire off the shoulder of Orion. I watched seabeams glitter in the dark near the Tannhauser gate. All those moments will be lost in time like tears in rain. Time to die." (Roy) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Monika Ferster wrote:> > 3 < 2 < 1 seems to be seen like a double no because 3 < 2 < 1 < 0 returns > F. It looks like the multiplication of -1 what is strange, because F > corresponds to the value 0.Not really because:> 5<4<3<2<1[1] FALSE> 4<3<2<1[1] FALSE> 3<2<1[1] TRUE Somehow 3<2<1 remains special. -- Michael T. Mader -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Why would you expect 1 > 1 to be True?i didnt't realize TRUE<-1 i thought TRUE was something like INF or so, because normally the following is false (like Duncan wrote):> In R like C, FALSE is 0 and TRUE is 1normally in C you define somewhat like #define FALSE ((unsigned long) 0) #define TRUE (~((unsigned long) 0)) (ok, there are more aesthetic ways, you can use "signed",...) but using binary negation makes much sense in many ways. so in C TRUE evaluates to max( long) (if you use the unsigned variant), and in fact i thought this would be the implementation in R as well... cu till -- "I have seen things you people wouldn't believe. Attack-ships on fire off the shoulder of Orion. I watched seabeams glitter in the dark near the Tannhauser gate. All those moments will be lost in time like tears in rain. Time to die." (Roy) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._