From a1973fb5f9ca183ab6df3933937fd10174d2bccb Mon Sep 17 00:00:00 2001 From: Jeff Zemla Date: Mon, 1 Dec 2025 15:26:22 -0500 Subject: [PATCH] Fixes issue #284, cor.mtest error on insufficient observations --- R/cor-mtest.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/R/cor-mtest.R b/R/cor-mtest.R index 89213b3..a899489 100644 --- a/R/cor-mtest.R +++ b/R/cor-mtest.R @@ -27,7 +27,14 @@ cor.mtest = function(mat, ...) { for (i in 1:(n - 1)) { for (j in (i + 1):n) { - tmp = cor.test(x = mat[, i], y = mat[, j], ...) + tmp = tryCatch({ + cor.test(x = mat[, i], y = mat[, j], ...) + }, + error = function(e) { + warning(conditionMessage(e)) + list(p.value = NA, + conf.int = NULL) + }) p.mat[i, j] = p.mat[j, i] = tmp$p.value # only 'pearson' method provides confidence intervals