Patrick and Bert,
Thank you both for you replies to my question. I see how my naïve expectations
fail to floating point arithmetic. However, I still believe there is an
underlying problem.
It seems to me that when asked,
c(7.7, 7.8, 7.9) %in% seq(4, 8, by=0.1)
[1] TRUE FALSE TRUE
R
Hello R-help,
I noticed the following surprising behavior when using %in% to find elements in
a vector generated using seq().
# weird!!!
c(7.7, 7.8, 7.9) %in% seq(4, 8, by=0.1)
[1] TRUE FALSE TRUE
# OK now
c(7.7, 7.8, 7.9) %in% round(seq(4, 8, by=0.1), 1)
[1] TRUE TRUE TRUE
# wait, how
2 matches
Mail list logo