library(MASS)
## Warning: package 'MASS' was built under R version 4.4.3
library(GGally)
## Warning: package 'GGally' was built under R version 4.4.3
## Loading required package: ggplot2
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
library(ggplot2)
#Create a subset with a few important variables 
boston_subset <- Boston[ , c("crim","rm","dis","lstat","medv")]


ggpairs(boston_subset,
        title = "Pairs of Selected Features from Boston Dataset")

##cnage the color of graph

# how to color the graph

# Select specific columns
boston_subset <- Boston[ , c("crim","rm","dis","lstat","medv")]

# Create a grouping variable
boston_subset$price_group <- ifelse(boston_subset$medv > median(Boston$medv), "High", "Low")


# Plot with color based on price_group which is i create only for making new coloumn for colorings 
ggpairs(boston_subset,
        columns = 1:5,  # exclude 'medv_group' from axes
        aes(color = price_group),
        title = "Pairs of Selected Features from Boston Dataset")