Learn R Programming

reproducible (version 2.1.2)

compareNA: NA-aware comparison of two vectors

Description

Copied from http://www.cookbook-r.com/Manipulating_data/Comparing_vectors_or_factors_with_NA/. This function returns TRUE wherever elements are the same, including NA's, and FALSE everywhere else.

Usage

compareNA(v1, v2)

Value

A logical vector, indicating positions where two vectors are same or differ.

Arguments

v1

A vector

v2

A vector

Examples

Run this code
a <- c(NA, 1, 2, NA)
b <- c(1, NA, 2, NA)
compareNA(a, b)

Run the code above in your browser using DataLab