near: Compare two numeric vectors

View source: R/near.R

nearR Documentation

Compare two numeric vectors

Description

This is a safe way of comparing if two vectors of floating point numbers are (pairwise) equal. This is safer than using ==, because it has a built in tolerance

Usage

near(x, y, tol = .Machine$double.eps^0.5)

Arguments

x, y

Numeric vectors to compare

tol

Tolerance of comparison.

Examples

sqrt(2) ^ 2 == 2
near(sqrt(2) ^ 2, 2)

dplyr documentation built on Nov. 17, 2023, 5:08 p.m.