Check whether two objects are the same, including patterns of NAs.

compFun(a, b)

Arguments

a

An object of a given type.

b

An object similar in type to that given above.

Value

Boolean object with TRUE indicating an element is the same.

Examples

x <- c(5, 8, 9, NA, 3, NA) y <- c(5, 2, 9, 4, NA, NA) compFun(x, y)
#> [1] TRUE FALSE TRUE FALSE FALSE TRUE
x <- matrix(rnorm(1000), ncol = 20) x[sample(seq(along = x), 100)] <- NA all(compFun(x, x))
#> [1] TRUE
dim(compFun(x, x))
#> [1] 50 20
x <- as.list(c(5, 8, 9, NA, 3, NA)) y <- as.list(y) sapply(compFun(x, y), function(a) sum(!a))
#> [1] 0 1 0 1 1 0
x <- as.data.frame(x) y <- as.data.frame(y) sum(!compFun(x, y))
#> [1] 3
#