Re: [R] Multiple comparisons: its a trap!

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon 26 Jul 2004 - 02:40:06 EST

Barry Rowlingson <B.Rowlingson@lancaster.ac.uk> writes:

> Liaw, Andy wrote:
> > Stupid me: fell into this trap:
> >

> >>0 == 0 == 0

2">> > [1] FALSE
> >
>
> Ouch!
>

> Python's comparison operators don't have this trap, since they

> unravel each comparison pair in a chain so that:
>

> (A op1 B op2 C)
>
> becomes:
>

>
(A op1 B) and (B op2 C)

[chop]

> Of course old hand Fortran programmers understand all this since the
> second thing they learnt (after learning how to tap the space bar six
> times) was the order of precedence of operators...

SAS does likewise, at least in recent versions. Whether this kind of syntactical exceptions is actually helpful is debatable. The problem is that you get to teach people that comparisons are binary operators except when they are not...

I wonder how Python actually manages this; doesn't look like something that is easy to implement in a yacc-style parser.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Jul 26 02:52:19 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:13 EST