I have a list of 41 numbers but when I run through a for loop, only 26 are recognized as included in that list; an example is 300, this number is in the list but Boolean operations "==" and "%in%" return false (see screenshot of R console). Does anyone know what the problem is?
Asked
Active
Viewed 14 times
0

lyonsja
- 11
- 3
-
1(1) Images of data are not helpful, I will not transcribe your data that you have in a textual format. (2) `==` and `%in%` with floating-point is problematic in any programming language, see https://stackoverflow.com/q/9508518, https://stackoverflow.com/q/588004, and https://en.wikipedia.org/wiki/IEEE_754. – r2evans Apr 27 '21 at 14:50
-
(3) No need for a `for` loop, you could have done the same with `sum(0:4000 %in% bind.iterations)`, though it may still fall short. Testing a similar set of data on my console does not reproduce the same results, though, so it's likely that your `bind.iterations` could stand some scrutiny (`as.integer` or `round(.,0)`, perhaps). – r2evans Apr 27 '21 at 14:52
-
If you want help with *you* version of `bind.iterations`, I suggest you include the output from `dput(bind.iterations)` so that we can see your numbers. Otherwise this is not reproducible. – r2evans Apr 27 '21 at 14:54