taiyun / corrplot

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

Error in cor.mtest(corrplotall, 0.95) : object 'lowCI.corrplotallll' not found #132

Closed Tai-Rocha closed 3 years ago

Tai-Rocha commented 6 years ago

Hi everyone, I tried many time to do Pearson test but i receive this message:

Error in cor.mtest(corrplotall, 0.95) :  object 'lowCI.corrplotallll' not found

My script is:

corrplotall <- read.csv(file.choose(), sep=";", dec=",", header=TRUE)

cor.mtest <- function(corrplotall, conf.level = 0.95) {
  mat <- as.matrix(corrplotall)
  n <- ncol(corrplotall)
  p.mat <- lowCI.corrplotall <- uppCI.corrplotallll <- matrix(NA, n, n)
  diag(p.mat) <- 0
  diag(lowCI.corrplotallll) <- diag(uppCI.corrplotallll) <- 1
  for (i in 1:(n - 1)) {
    for (j in (i + 1):n) {
      tmp <- cor.test(corrplotall[, i], corrplotallll[, j], conf.level = conf.level)
      p.mat[i, j] <- p.mat[j, i] <- tmp$p.value
      lowCI.corrplotall[i, j] <- lowCI.corrplotall[j, i] <- tmp$conf.int[1]
      uppCI.corrplotall[i, j] <- uppCI.corrplotall[j, i] <- tmp$conf.int[2]
    }
  }
  return(list(p.mat, lowCI.corrplotall, uppCI.corrplotall))
}

res1 <- cor.mtest(corrplotall, 0.95)
res2 <- cor.mtest(corrplotall, 0.99)

corrplot(corrplotall, p.mat = res1[[1]], sig.level = 0.05)
corrplot(corrplotall, p.mat = res1[[1]], insig = "p-value")
corrplot(corrplotall, p.mat = res1[[1]], insig = "p-value", sig.level = -1)