## Correlation Using ggcorrplot

#The hypothetical data frame,

#Lets say,

>A <- c(2, 4, 6, 8, 12, 5, 7,8)
>B <- c(4,5,6,2,9,13,2, 6)
>C <- c(3,5,7,2,4,8,3,6)
>D <- c(4,6,2,5,7,4,6,9)

DD <- data.frame(A,B,C, D)

##### #correlation with package ggcorrplot – installing the package and importing the library

install.packages(“ggcorrplot”)
library(“ggcorrplot”)

##### #doing the correlation test using pearson method and assigning the results to variable CORT

CORT <- cor (DD, method = “pearson”)

##### #now plotting with ggcorrplot

ggcorrplot(CORT, hc.order = TRUE)

##### #calculating the matrix with p value

p.mat <- cor_pmat(DD)

##### #Plotting with p-value (non-significant coefficients are crossed)

ggcorrplot(CORT, hc.order = TRUE, p.mat = p.mat)

##### #plotting with the ggcorrplot with modified arguments and p value

ggcorrplot(COR, hc.order = TRUE, p.mat = p.mat, colors = c(“red”,”green”, “blue”))

##### # plotting only the lower half

ggcorrplot(COR, hc.order = TRUE, p.mat = p.mat, type = “lower”)

##### #with logical values

ggcorrplot(COR, hc.order = TRUE, p.mat = p.mat, type = “lower”, lab = TRUE)

##### #with method = circle

ggcorrplot(COR, hc.order = TRUE, p.mat = p.mat, type = “lower”, method = “circle”)

##### #with outline

ggcorrplot(COR, hc.order = TRUE, p.mat = p.mat, type = “lower”, outline.color = “black”)