Oddly Specific

A Blog About Data Science and Reproducible Research

When 0.1 + 0.2 Does Not Equal 0.3

Rewriting R's %in% operator to match floating point values

I explain the dangers of using == and R’s %in% operator with decimal values and how dplyr::near can be used instead of ==. I also show how to overload the %in% operator to perform safe approximate matching of numeric vectors.