eq: NA-Friendly Equality Comparison

View source: R/eq.R

eqR Documentation

NA-Friendly Equality Comparison

Description

Vectorized flexible equality comparison which considers NAs as a value. Returns TRUE if both values are NA, and FALSE when only one is NA. The standard == comparison returns NA in both of these cases and sometimes this is interpreted unexpectedly. Author: Bryce Chamberlain. Tech Review: Maria Gonzalez.

Usage

eq(x, y, do.nanull.equal = TRUE)

Arguments

x

First vector/value for comparison.

y

Second vector/value for comparison.

do.nanull.equal

Return TRUE if both inputs are NA or NULL (tested via easyr::nanull).

Value

Boolean vector/value of comparisons.

Examples

c(NA,'NA',1,2,'c') == c(NA,NA,1,2,'a') # regular equality check.
eq(c(NA,'NA',1,2,'c'),c(NA,NA,1,2,'a')) # check with eq.

easyr documentation built on March 31, 2023, 6:22 p.m.

Related to eq in easyr...