Develop a R program to calculate and visualize a corelation matrics for a given data set with colour coded cells indicating the strength and direction of corelations using ggplot2’s geom_tile function
step1 load the required libraries
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
library(reshape2)
Attaching package: 'reshape2'
The following object is masked from 'package:tidyr':
smiths
# Use a sample dataset (replace mtcars with your own dataset if needed)data <- mtcars# Step 1: Calculate the correlation matrixcor_matrix <-cor(data)# Step 2: Convert the matrix to a long format data framecor_df <-melt(cor_matrix)