Learn R Programming

nima (version 0.5.0)

compFun: Compare Two Similar Objects including Missing Data Patterns.

Description

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

Usage

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

Run this code
# NOT RUN {
x <- c(5, 8, 9, NA, 3, NA)
y <- c(5, 2, 9, 4, NA, NA)
compFun(x,y)

x <- matrix(rnorm(1000), ncol = 20)
x[sample(seq(along = x), 100)] <- NA
all(compFun(x,x))
dim(compFun(x,x))

x <- as.list(c(5, 8, 9, NA, 3, NA))
y <- as.list(y)
sapply(compFun(x,y), function(a) sum(!a))

x <- as.data.frame(x)
y <- as.data.frame(y)
sum(!compFun(x,y))
# }

Run the code above in your browser using DataLab