Correlation using corrplot package
Must install RColorBrewer package
Install corrplot package
install.packages("corrplot")
Load corrplot package
library(corrplot)
## corrplot 0.92 loaded
Install RColorBrewer package
install.packages("RColorBrewer")
Load RColorBrewer package
library(RColorBrewer)
Command line for correlation
corr<-cor(Data,use="complete.obs")
corr1<-as.matrix(corr)
res1 <- cor.mtest(corr, conf.level = .95)
res2 <- cor.mtest(corr, conf.level = .99)
corrplot(corr, p.mat = res1$p, method="circle", type = "lower",insig = "label_sig",
sig.level = c(.001, .01, .05), pch.cex = 1.2,
pch.col = "black",col = col4(10),tl.col = "black")
Load data from website or upload from Excel/Text
Corrdata<-read.csv(file='https://gist.githubusercontent.com/ikmalmal/7ffb1b3d93ce0b00b9da50859a710471/raw/414c2a2089e34f258f0fbf93bbfdbf93a069bcec/paddy.csv')
Specify the color
col1 <- colorRampPalette(c("#7F0000", "red", "#FF7F00", "yellow", "white", "cyan", "#007FFF", "blue", "#00007F"))
col2 <- colorRampPalette(c("#67001F", "#B2182B", "#D6604D", "#F4A582","#FDDBC7", "#FFFFFF", "#D1E5F0", "#92C5DE","#4393C3", "#2166AC", "#053061"))
col3 <- colorRampPalette(c("red", "white", "blue"))
col4 <- colorRampPalette(c("#7F0000", "red", "#FF7F00", "yellow", "#7FFF7F","cyan", "#007FFF", "blue", "#00007F"))
col5 <- colorRampPalette(c("#00007F","blue","#007FFF","cyan","yellow", "#7FFF7F","pink","#E6218A","#FF0637","#CD0606"))
whiteblack <- c("white", "black")
fit your data to this command
corr<-cor(Corrdata,use="complete.obs")
corr1<-as.matrix(corr)
res1 <- cor.mtest(corr, conf.level = .95)
res2 <- cor.mtest(corr, conf.level = .99)
corr1
## PH NP GY TGW
## PH 1.00000000 0.32984760 0.3882771 -0.03436953
## NP 0.32984760 1.00000000 0.4298143 -0.09667572
## GY 0.38827708 0.42981431 1.0000000 -0.10210817
## TGW -0.03436953 -0.09667572 -0.1021082 1.00000000
choose col4. To choose other colors, change the color spectrum
code
col4 <- colorRampPalette(c("#7F0000", "red", "#FF7F00", "yellow", "#7FFF7F","cyan", "#007FFF", "blue", "#00007F"))
plot1<-corrplot(corr, p.mat = res1$p, method="circle", type = "lower",insig = "label_sig",
sig.level = c(.001, .01, .05), pch.cex = 1.2,
pch.col = "black",col = col4(10),tl.col = "black")

Using different color, col5
col5 <- colorRampPalette(c("#00007F","blue","#007FFF","cyan","yellow", "#7FFF7F","pink","#E6218A","#FF0637","#CD0606"))
plot2<-corrplot(corr, p.mat = res1$p, method="circle", type = "lower",insig = "label_sig",
sig.level = c(.001, .01, .05), pch.cex = 1.2,
pch.col = "black",col = col5(10),tl.col = "black")
