Develop a program to create co relation matrix for a given data set with color coded sets indicating the strength and direction of co-relation using ggplot2 (geom_tile)
step 1: load required library
library(ggplot2)library(tidyr)library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
ggplot(cor_df, aes(x=Var1,y=Var2,fill=Freq))+geom_tile(color="black")+scale_fill_gradient2(low ="violet",mid="white",high="red",midpoint=0,limit=c(-1,1),name="Correlation" )+geom_text(aes(label=round(Freq,2)),size=3)+theme_minimal()+labs(title="co-relation matrix with color code",x="var1",y="var2")+theme(axis.text.x=element_text(angle=45,hjust=1))