taiyun / corrplot

A visual exploratory tool on correlation matrix
https://github.com/taiyun/corrplot
Other
317 stars 86 forks source link

Error in cor.mtest when there are not enough finite observations #284

Open Gael-Hammer opened 1 week ago

Gael-Hammer commented 1 week ago

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)
      }