Learn R Programming

easyr (version 0.5-11)

eq: 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)

Value

Boolean vector/value of comparisons.

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).

Examples

Run this code
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.

Run the code above in your browser using DataLab