[R] Numbers that look equal, should be equal, but if() doesn
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Thu May 29 01:03:19 CEST 2003
On 28-May-03 Barry Rowlingson wrote:
> Oh, why not just go one step further, and redefine the == operator!
>
> "==" <- function(x,y){equal.enough(x,y)}
>
> before:
> > (.1+.2)==.3
> [1] FALSE
>
> after:
> > (.1+.2)==.3
> [1] TRUE
>
> This requires a slight modification to equal.enough, which I will not
> list here, so that people dont _actually_ do this. It just ensures that
> equal.enough doesn't go all infinitely recursive on us.
>
> Next time on useless R tips: 1 + 1 = 3
At which point I am unable to resist quoting:
"2 plus 2 is never equal to 5 -- even for large values of 2".
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 29-May-03 Time: 00:03:19
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list