|||
如何做出相关系数矩阵可视化图
install.packages("psych")install.packages("corrplot")#安装包,如果已安装,请略过
library(psych)
library(corrplot)#载入两个包
data(iris)#机器学习常用神奇数据集——鸢尾花数据集
head(iris)#查看下数据集前五行
irisnew<-iris[,-5]#去除第五列种类变量
cormat<-corr.test(irisnew)#相关系数分析及显著性检验#最简单的相关系数矩阵可视化
corrplot(cormat$r)
corrplot(cormat$r,method=”square”)
corrplot(cormat$r,method = “number”)
corrplot(cormat$r,method = “shade”)
corrplot(cormat$r,method=”ellipse”)
corrplot(cormat$r,method = “pie”)
corrplot(cormat$r,method=”square”,type=”lower”,title = “Correlation of iris”)
cormatp<-cormatr,method=”square”,type=”lower”,title = “Correlation of iris”,tl.cex=1.5,tl.pos = “lt”,number.cex=1,p.mat=cormatp,sig.level=0.05,insig=c(“pch”))
corrplot(cormat$r,method=”square”,type=”full”,title = “Correlation of iris”,tl.cex=1.5,tl.pos = “lt”,number.cex=1,p.mat=cormatp,sig.level=0.05,insig=c(“pch”))
corrplot.mixed(cormat$r,upper = “square”,lower = “number”,diag = “u”,tl.cex=1.5,tl.pos = “lt”,number.cex=1,p.mat=cormatp,sig.level=0.05,insig=c(“pch”))
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-4 21:20
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社