Introduction

The PM2.5 pollutant is the primary metric used in this investigation to evaluate the air quality of four major cities: Seoul, New Delhi, Mumbai, and Dhaka. PM2.5 stands for fine particulate matter. Because of its minuscule size and ability to thoroughly penetrate the respiratory system, it is frequently regarded as one of the most dangerous air pollutants. The problems with air quality that densely populated areas experience can be better understood by comparing and analyzing the PM2.5 levels in these various metropolitan centers. This analysis attempts to analyze and examine the trends in PM2.5, highlighting the consequences for environmental and public health policy in different metropolitan areas through data-driven insights and visualizations.

getwd()
## [1] "E:/R Classes"
Data <-read.csv("air_quality_data.csv")
View(Data)

#Barplot Visualization 1

library(ggplot2)
ggplot(data = Data, aes(x=Date, y=Dhaka.PM2.5, fill="#3498DB")) +
  geom_bar(stat = "identity")+
  labs(title = "Change in PM2.5 for BD in last five years")+theme_light()
## Warning: Removed 1798 rows containing missing values (`position_stack()`).

Interpretation:

Here, last five years of daily data of PM2.5 is taken for Dhaka to see the changes in AQI in Bangladesh. In the past five years, the AQI is seen to be fluctuacuating drastically. Most of the days the PM2.5 is seen to be 200-300+ which indicated very poor quality of air in Bangladesh.

#Visualization 2 - BoxPlot

# Load necessary libraries
library(ggplot2)

# Combine Dhaka and Mumbai data for the boxplot
combined_data <- rbind(
  data.frame(City = "Dhaka", PM2.5 = Data$Dhaka.PM2.5),
  data.frame(City = "Mumbai", PM2.5 = Data$Mumbai.PM2.5)
)

# Create a boxplot
ggplot(combined_data, aes(x = City, y = PM2.5, fill = City)) +
  geom_boxplot() +
  labs(title = "PM2.5 Levels Comparison between Dhaka and Mumbai",
       x = "City", y = "PM2.5") +
  theme_minimal()
## Warning: Removed 3596 rows containing non-finite values (`stat_boxplot()`).

Interpretation:

As can be seen from the box plot comparison, Dhaka typically has higher PM2.5 levels (100–200) than Mumbai (50–150). Compared to Mumbai’s somewhat lower but still diverse pollution range, Dhaka’s range suggests a continuously greater pollution level, possibly indicating more environmental issues or sources of particle matter.

#Visualization 3 - BarChart

# Calculate average PM2.5 levels for Dhaka and Seoul
avg_pm2.5 <- c(mean(Data$Dhaka.PM2.5, na.rm = TRUE),
              mean(Data$Seoul.PM2.5, na.rm = TRUE))

# Create a data frame for the bar chart
city_data <- data.frame(
  City = c("Dhaka", "Seoul"),
  Average_PM2.5 = avg_pm2.5
)

# Create a bar chart
ggplot(city_data, aes(x = City, y = Average_PM2.5, fill = City)) +
  geom_bar(stat = "identity") +
  labs(title = "Average PM2.5 Levels Comparison between Dhaka and Seoul",
       x = "City", y = "Average_PM2.5") +
  theme_minimal()

Interpretation:

The bar graph clearly illustrates the significant difference in average PM2.5 levels between Seoul and Dhaka. With an average PM2.5 of more than 150, Dhaka has consistently high pollution levels. On the other hand, Seoul’s Average PM2.5, which is located at approximately 75, indicates comparatively lower but still alarming PM2.5 concentrations. This sharp difference draws attention to Dhaka’s serious air quality issues, which may have several causes, while highlighting Seoul’s somewhat better—though not completely benign—air quality circumstances in this specific setting.

#Visualization 4 - Interactive Scatterplot

# Load necessary libraries
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
aqi<-ggplot(Data, aes(x=Dhaka.PM2.5, y=New_Delhi.PM2.5)) + 
  geom_point(col="steelblue", size=1) +   # Set static color and size for points
  geom_smooth(method="lm", col="firebrick") +  # change the color of line
  coord_cartesian(xlim=c(20, 400), ylim=c(0, 400)) + 
  labs(title="Dhaka_AQI vs NewDelhi_AQI", subtitle="From Air_Quality dataset", y="New_Delhi", x="Dhaka", caption="AQI of Two Cities")
aqi
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 1798 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 1798 rows containing missing values (`geom_point()`).

ggplotly(aqi)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 1798 rows containing non-finite values (`stat_smooth()`).

Interpretation:

Interesting insights are shown by the interactive scatterplot of PM2.5 levels over the last five years, with Dhaka on the x-axis and New Delhi on the y-axis. Plotting the pollution levels of the two cities shows a positive correlation, suggesting that the trends in PM2.5 concentrations are similar. But New Delhi’s PM2.5 values are always greater than Dhaka’s, suggesting that the city has a heavier pollution load. Though different, there are sporadic rises in both cities, suggesting that they share pollution occurrences. This illustration highlights New Delhi’s ongoing battle with noticeably high air pollution levels and illustrates the different pollution dynamics between these two large cities.

Conclusion:

Different air quality profiles were revealed by means of extensive visualizations that included boxplots, bar charts, scatterplots, and interactive displays of PM2.5 data from Dhaka, Mumbai, New Delhi, and Seoul. Every day, Dhaka showed noticeably the highest PM2.5 readings—more than 150—indicating serious pollution issues. Mumbai and Seoul demonstrated lower but still alarming ranges, while New Delhi continuously showed high levels around 150. These visuals brought attention to the ongoing challenges that Dhaka and New Delhi face due to significantly higher pollution levels, emphasizing the need for immediate action. Even with their relative improvements, Mumbai and Seoul still struggle with poor air quality, which highlights the need to reduce pollution in these cities for healthier environments.