Hello,

Watch out for operator precedence.



all.equal(0.3, 0.1*3)
#[1] TRUE


`%~~%` <- function (e1, e2)  all.equal(e1, e2)

0.3 %~~% 0.1*3
#Error in 0.3 %~~% 0.1 * 3 : argumento não-numérico para operador binário


0.3 %~~% (0.1*3)
#[1] TRUE


Now with isTRUE. The problem changes a bit.


isTRUE(all.equal(0.3, 0.1*3))
#[1] TRUE


`%~~%` <- function (e1, e2)  isTRUE(all.equal(e1, e2))

0.3 %~~% 0.1*3
#[1] 0

0.3 %~~% (0.1*3)
#[1] TRUE


Hope this helps,

Rui Barradas

Às 08:20 de 03/09/2018, Juan Telleria Ruiz de Aguirre escreveu:
Maybe a new Operator could be defined for a fast and easy double
Comparison: `~~`

`~~` <- function (e1, e2)  all.equal(e1, e2)

And document it properly.

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to