How is this possible:
> match(1.68, seq(0.01,10, by = .01))
[1] 168
> match(1.67, seq(0.01,10, by = .01))
[1] NA
Does the R function match
have a bug in it?
Typical R-FAQ 7.31 problem. Not a bug. To avoid this common user error, use instead the function findInterval and fuzz the boundaries down a bit. (or do your selections on integer sequences.)
> findInterval(1.69, seq(0.01,10, by = .01))
[1] 169
> findInterval(1.69, seq(0.01,10, by = .01)-.0001)
[1] 169
> findInterval(1.68, seq(0.01,10, by = .01)-.0001)
[1] 168
> findInterval(1.67, seq(0.01,10, by = .01)-.0001)
[1] 167
> findInterval(1.66, seq(0.01,10, by = .01)-.0001)
[1] 166
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With