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 FALSE > seq(0, 1, by=0.1) %==% 0.2 [1] FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > seq(0, 1, by=0.1) %==% 0.3 [1] FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > seq(0, 1, by=0.1) %==% 0.4 [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE > 0.3 %==% seq(0, 1, by=0.1) [1] FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
On Mon, Jun 8, 2009 at 4:45 PM, Grześ<gregori...@gmail.com> wrote: > > 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 FALSE > > -- > View this message in context: > http://www.nabble.com/seq%28...%29-strange-logical-value-tp23920374p23920374.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.