How about this:
> "%==%" <- function(x, y) {
if (length(x) > 1) {
sapply(x, function(z) isTRUE(all.equal(z, y)));
} else {
sapply(y, function(z) isTRUE(all.equal(z, x)));
}
}
> seq(0, 1, by=0.1) %==% 0.1
[1] FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALS
Allan Engelhardt wrote:
> See
> http://wiki.r-project.org/rwiki/doku.php?id=misc:r_accuracy:decimal_numbers#sequences_of_decimal_numbers
>
>
as usual, be careful about what is advertised in r docs and related
texts. on the r_accuracy page, you'll read:
"For further information, see the digit
See
http://wiki.r-project.org/rwiki/doku.php?id=misc:r_accuracy:decimal_numbers#sequences_of_decimal_numbers
and also
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
GrzeÅ wrote:
> Do you heve any idea why I get after this instruction everywh
http://wiki.r-project.org/rwiki/doku.php?id=misc:r_accuracy:decimal_numbers
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
GrzeÅ wrote:
> Do you heve any idea why I get after this instruction everywhere false?
>
>> seq (0, 1, by=0.1) == 0.3
Do you heve any idea why I get after this instruction everywhere false?
> seq (0, 1, by=0.1) == 0.3
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
But after different step it's ok:
> seq(0, 1, by=0.1) == 0.4
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
5 matches
Mail list logo