0

The R code and error is showing below:

> x = seq(0,1,by=0.2)
> stopifnot( x == c(0.0,0.2,0.4,0.6,0.8,1.0))
Error: x == c(0, 0.2, 0.4, 0.6, 0.8, 1) are not all TRUE

I'm a new learn of R and cannot figure out why, can somebody help, thank you!

rac
  • 1
  • 4
    Since `all.equal(seq(0,1,by=0.2), c(0.0,0.2,0.4,0.6,0.8,1.0))` returns `TRUE`, I'm assuming it's a floating point representation issue. – alistaire Sep 08 '16 at 04:45
  • 4
    To see the problem: `print(rbind(seq(0,1,by=0.2), c(0.0,0.2,0.4,0.6,0.8,1.0)), digits = 22)` – alistaire Sep 08 '16 at 04:49

0 Answers0