Search code examples
rinequalities

First circle of R hell. 0.1 != 0.3/3


Possible Duplicate:
Numeric comparison difficulty in R

Hello All,

According to "R Inferno" paper. I'm right now in the first circle of R hell. This is where pagans expect 0.1 == 0.3/3. Paper recommends using all.equal function for such cases, however I need to check ">=" or "<=" conditions. With current example on of them fail:

> .1 >= .3/3
[1] TRUE
> .1 <= .3/3
[1] FALSE

Is there a similar function to all.equal that checks inequalities?

Thank you,

Ilya


Solution

  • See these questions:

    Generally speaking, you can deal with this by including a tolerance level as per the second link above.