1.Information about plotting of correlation,

#Creating the variables
# Load necessary libraries
#install.packages("corrplot")  # Install package if not already installed
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.4.3
## corrplot 0.95 loaded
# Step 1: Create 5 variables with 20 random values
set.seed(123)  # For reproducibility
x1 <- rnorm(20, mean=50, sd=10)  # Normal distribution with mean=50, sd=10
x2 <- rnorm(20, mean=30, sd=5)
x3 <- rnorm(20, mean=40, sd=7)
x4 <- rnorm(20, mean=60, sd=15)
x5 <- rnorm(20, mean=20, sd=3)

# Step 2: Combine into a data frame
data <- data.frame(x1, x2, x3, x4, x5)

# Step 3: Compute correlation matrix
cor_matrix <- cor(data)

# Step 4: Create correlation plot (corrplot)
corrplot(cor_matrix, method="color", addCoef.col="black", tl.cex=0.8)

# Step 5: Scatter Plot Matrix (Pairwise scatter plots)
pairs(data, main="Scatter Plot Matrix of Variables", pch=19, col="blue")

corrplot(cor_matrix, method="color", col= colorRampPalette(c("red", "white", "blue"))(200), 
         addCoef.col="black", tl.cex=0.8, number.cex=0.8)

2.Displaying the above information about correlation in other shapes

# Load necessary library
library(corrplot)

# Generate a correlation matrix
cor_matrix <- cor(data)

# 1️⃣ Display as a "circle" matrix
corrplot(cor_matrix, method="circle", addCoef.col="black", tl.cex=0.8)

# 2️⃣ Display as a "square" matrix
corrplot(cor_matrix, method="square", addCoef.col="black", tl.cex=0.8)

# 3️⃣ Display as an "ellipse" matrix
corrplot(cor_matrix, method="ellipse", addCoef.col="black", tl.cex=0.8)

# 4️⃣ Display as "number" matrix (Only numeric values)
corrplot(cor_matrix, method="number", col="black", number.cex=1.2)

# 5️⃣ Display as "mixed" matrix (Upper part with numbers, lower part with circles)
corrplot(cor_matrix, method="color", type="upper", addCoef.col="black", tl.cex=0.8)
corrplot(cor_matrix, method="circle", type="lower", addCoef.col="black", tl.cex=0.8, add=TRUE)