What's the difference between identical(x, y) and isTRUE(all.equal(x, y))?

后端 未结 3 503
渐次进展
渐次进展 2020-12-02 20:28

Is there any difference between testing isTRUE(all.equal(x, y)) and identical(x, y)?

The help page says:

Don\'t use

3条回答
  •  暖寄归人
    2020-12-02 20:45

    all.equal tests for near equality, while identical is more exact (e.g. it has no tolerance for differences, and it compares storage type). From ?identical:

    The function ‘all.equal’ is also sometimes used to test equality this way, but was intended for something different: it allows for small differences in numeric results.

    And one reason you would wrap all.equal in isTRUE is because all.equal will report differences rather than simply return FALSE.

提交回复
热议问题