is.element() doesn't check correctly (?) in R -
i got little weird problem here:
setprogress <- function(total) { ticks <- seq(.01, 1, = 0.01) * total return(ticks) } ticks <- setprogress(10000) is.element(100, ticks) is.element(205, ticks) # ... is.element(700, ticks) if run code get:
clearly 100 part of vector ticks. -> true
205 not. -> false
700 is part of ticksbut receive output false.
what going on here?
cheers, martin
it's rounding error. set options(digits=22) , view ticks. you'll find value: 7000.0000000000009094947
the error because 0.7 cannot represented binary floating point number.
you may able fix using definition:
setprogress <- function(total) { seq(total/100, total, length=100) }
Comments
Post a Comment