0
我不知道我應該把像corrplot的代碼method=」spearman」
看到sperman相關Corrplot意義
cor.mtest <- function(mat, conf.level = 0.95){
mat <- as.matrix(mat)
n <- ncol(mat)
p.mat <- lowCI.mat <- uppCI.mat <- matrix(NA, n, n)
diag(p.mat) <- 0
diag(lowCI.mat) <- diag(uppCI.mat) <- 1
for(i in 1:(n-1)){
for(j in (i+1):n){
tmp <- cor.test(mat[,i], mat[,j], conf.level = conf.level)
p.mat[i,j] <- p.mat[j,i] <- tmp$p.value
lowCI.mat[i,j] <- lowCI.mat[j,i] <- tmp$conf.int[1]
uppCI.mat[i,j] <- uppCI.mat[j,i] <- tmp$conf.int[2]
}
}
return(list(p.mat, lowCI.mat, uppCI.mat))
}
res1 <- cor.mtest(mtcars,0.95)
將'method ='spearman''添加到'cor.mtest'函數中的參數中,以便它成爲默認值(如果需要,用戶可以稍後更改它)。您還需要在'tmp < - cor.test'這行中添加'method = method' – rawr
這不是一個非常有效的實現。但是,主要問題是它不會調整多個測試的p.values。 – Roland