|
大致相等用all.equal 就可以,里面有参数可以设置的。
Some more examples of using all.equal instead of == (the last example is supposed to show that this will correctly show differences).
> 0.1+0.05==0.15
[1] FALSE
> isTRUE(all.equal(0.1+0.05, 0.15))
[1] TRUE
> 1-0.1-0.1-0.1==0.7
[1] FALSE
> isTRUE(all.equal(1-0.1-0.1-0.1, 0.7))
[1] TRUE
> 0.3/0.1 == 3
[1] FALSE
> isTRUE(all.equal(0.3/0.1, 3))
[1] TRUE
> 0.1+0.1==0.15
[1] FALSE
> isTRUE(all.equal(0.1+0.1, 0.15))
[1] FALSE
|