[R] Creating logical value from the difference of two absolute values

Nathan Leon Pace, MD, MStat N.L.Pace at m.cc.utah.edu
Fri Nov 19 01:52:57 CET 2004


Using R 2.0.1 on Mac g5 running Mac OS X 10.3.6.

I would expect that

abs(.7 - .5) >= abs(.3 - .5) should be returned TRUE.


 > www <- abs(.7 - .5) >= abs(.3 - .5)
 > www

Is this a result of floating point or the implementation of abs or 
something else?

In a function I need to compare two absolute values - each being of the 
form |variable - constant|.

Any suggestions for implementing this correctly?


More information about the R-help mailing list