cor.mtest is basically a loop calling cor.test(x = mat[, i], y = mat[, j], ...)
When combinations of x and y do not have enough data, cor.test fails and thus cor.mtest.
Please catch this error, maybe with something along these lines:
if(sum(!is.na(mat[,i]*mat[,j])) > 2) {
tmp = cor.test(x = mat[, i], y = mat[, j], ...)
} else {
tmp <- list(p.value = NA, conf.int = NULL)
}
cor.mtestis basically a loop callingcor.test(x = mat[, i], y = mat[, j], ...)When combinations of x and y do not have enough data, cor.test fails and thus cor.mtest.
Please catch this error, maybe with something along these lines: