is_near: Compare two numeric vectors

Description Usage Arguments Value Examples

View source: R/is_near.R

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. This function is based on 'dplyr::near()'.

Usage

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

Arguments

x, y

Numeric vectors to compare

tol

tolerance of comparison (optional)

Value

a logical array (same size as input arrays) with element-wise comparison of 'x' and 'y“

Examples

1
2
sqrt(2)^2 == 2
is_near(sqrt(2)^2, 2)

GJMeijer/FBMcw documentation built on Dec. 17, 2021, 9:23 p.m.