r-如何绘制corr.test输出



我有两个行数相同、列数不同的数据帧。我使用从psych包执行corr.test

Correlations <- corr.test(final_x, final_y, use = "pairwise", alpha=0.05, method = "spearman")

现在,在运行corr.test之后,我确实有了输出(例如Correlations(。我可以单独保存Correlation$pCorrelation$r并制作热图。

但我的问题是,我想有一个Correlation本身的对角线图,Correlation$p在图的右上角,Correlations$r在图的左下角。

我试过了,但没有帮助:

corPlot(Correlations,numbers=TRUE,colors=TRUE,n=51,main=NULL,zlim=c(-1,1),
show.legend=TRUE, labels=NULL,n.legend=10,keep.par=TRUE,select=NULL, pval=NULL,  
cuts=c(.001,.01),scale=TRUE,cex,MAR,upper=TRUE,diag=TRUE, symmetric=TRUE,stars=FALSE,
adjust="holm",xaxis=1, xlas=0,ylas=2,gr=NULL,alpha=.75,min.length=NULL)

如果你能给我一些帮助就太好了。

谢谢

这个例子可能会有所帮助:

mcor <- cor(mtcars) # correlation matrix
mcor
mydata=mtcars
library(corrplot)
corrplot(mcor, type="upper", order="hclust", tl.col="black", tl.srt=45) # print correlation 

打印散点图:

library("ggpubr")
data=iris
str(data)
ggscatter(data, x = "Sepal.Length", y = "Petal.Length", 
add = "reg.line", conf.int = TRUE, 
cor.coef = TRUE, cor.method = "pearson",
xlab = "xlab", ylab = "ylab")

用于绘图;

library("ggpubr")
library("Hmisc")
mydata=mtcars
mydata.rcorr = rcorr(as.matrix(mydata))
mydata.coeff = mydata.rcorr$r
mydata.p = mydata.rcorr$P
plot(mydata.coeff,mydata.p)

最新更新