Is there a concise way to test whether some number X is within the bounds of another number Y plus or minus some small tolerance?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
all.equalcommand allows for atoleranceparameter so that differences less than the tolerance value are ignored.Personally, I am rather fond of
all.equalas an alternative toidentical, as it is far more informative. It is applicable to objects that are more general than just a single value (e.g. variable1 and variable2), such as data frames, lists, and more. So, although it will do the trick for your question, it is also more general for when you would like to consider whether two data frames are very nearly the same. This is quite useful when the differences are based on issues in numerical precision very close to the machine tolerance.