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)

Pairplot

create subset with a few important variables

boston_subset <- Boston[, c("crim", "rm", "age","dis","lstat", "medv")]

We made a subset of the Boston dataset with a few important variables. The variables are: crim, rm, age, dis, lstat. medv

Create pairplot with colors

ggpairs(boston_subset, 
        aes(color = as.factor(ifelse(crim > median(crim), "High Crime", "Low Crime")))) +
  scale_color_manual(values = c("High Crime" = "red", "Low Crime" = "blue")) +
  theme_minimal()

The pairplot shows the relationships between the variables in the subset. The points are colored based on whether the crime rate is above or below the median. The red points represent high crime areas, while the blue points represent low crime areas.