R/mx.com.R

Defines functions mx.com

mx.com <- function(x, y)
{
    if(is.matrix(x) & is.matrix(y)) {
        if(sum(dim(x) == dim(y)) != 2)
            stop("matrices have different dimensions")
    }
    x <- as.vector(x)
    y <- as.vector(y)
    if(length(x) != length(y))
        stop("vector lengths unequal")
    na.same <- is.na(x) == is.na(y) # NA status of x & y
    na.diff <- sum(!na.same)
    if(!na.diff) {
        xy.same <- x[!is.na(x)] == y[!is.na(y)] 
    # number status of x & y
        xy.diff <- sum(!xy.same)
    }
    else xy.diff <- 1
    return(!xy.diff)
}

Try the mfp package in your browser

Any scripts or data that you put into this service are public.

mfp documentation built on July 26, 2023, 5:30 p.m.