R语言相关矩阵表
#loading required packages
library(Hmisc)
# correlation matrix --------------
# # data subset for multivariate test for normality [matrix form is required]
corTotal <- data.frame(subset(data,select = c(BeckT,mindT,dshT)))
# delete NA
corTotal <- corTotal[complete.cases(corTotal),]
#multivariate normality tests[requires MVN packages]
mnormal <- mvn(corTotal)
mnormal
# correlation--------------------
res <- cor(as.matrix(corTotal))
res <- round(res,3)
res
#output the R and p-value
res2 <- rcorr(as.matrix(corTotal),type = "spearman")
r <- round(res2$r,3)
r
P <- round(res2$P,3)
P
#p <- res2$P
#
sheets <- list("sheet1" = r, "sheet2" = P)
openxlsx::write.xlsx(sheets,file = "总分相关矩阵.xlsx")