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

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

From: Bill Oliver (wloliver@qwest.net)
Date: Fri 06 Jul 2001 - 23:29:38 EST


Message-id: <002d01c1061f$b4c3acc0$9256e43f@91qez>


----- Original Message -----
From: "Till Baumgaertel" <till.baumgaertel@epost.de>
To: <r-help@stat.math.ethz.ch>
Cc: "Uwe Ligges" <ligges@statistik.uni-dortmund.de>
Sent: Friday, July 06, 2001 5:21 AM
Subject: Re: [R] a < b < c is alway TRUE

> > 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.

TRUE is being treated as equal to 1, so TRUE >= 1, returns TRUE. However,
non-zero values are treated as TRUE when coercing numerical values.

> as.logical(c(-2,-1,-.5,0,.5,1,2))
[1] TRUE TRUE TRUE FALSE TRUE TRUE TRUE

-Bill

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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:19 EST