Overview

Overview

   country             state               city             station         
 Length:3317        Length:3317        Length:3317        Length:3317       
 Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character  
                                                                            
                                                                            
                                                                            
                                                                            
 last_update           latitude        longitude     pollutant_id      
 Length:3317        Min.   : 8.515   Min.   :70.91   Length:3317       
 Class :character   1st Qu.:19.058   1st Qu.:75.58   Class :character  
 Mode  :character   Median :23.218   Median :77.31   Mode  :character  
                    Mean   :22.620   Mean   :78.56                     
                    3rd Qu.:27.169   3rd Qu.:80.32                     
                    Max.   :31.620   Max.   :94.64                     
                                                                       
 pollutant_min    pollutant_max    pollutant_avg   
 Min.   :  1.00   Min.   :  1.00   Min.   :  1.00  
 1st Qu.:  4.00   1st Qu.: 14.00   1st Qu.:  9.00  
 Median : 12.00   Median : 35.00   Median : 23.00  
 Mean   : 18.17   Mean   : 50.08   Mean   : 30.72  
 3rd Qu.: 24.00   3rd Qu.: 67.00   3rd Qu.: 43.00  
 Max.   :250.00   Max.   :500.00   Max.   :344.00  
 NA's   :268      NA's   :268      NA's   :268     

structure

spc_tbl_ [3,317 × 11] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ country      : chr [1:3317] "India" "India" "India" "India" ...
 $ state        : chr [1:3317] "Andhra_Pradesh" "Andhra_Pradesh" "Andhra_Pradesh" "Andhra_Pradesh" ...
 $ city         : chr [1:3317] "Amaravati" "Amaravati" "Anantapur" "Chittoor" ...
 $ station      : chr [1:3317] "Secretariat, Amaravati - APPCB" "Secretariat, Amaravati - APPCB" "Gulzarpet, Anantapur - APPCB" "Gangineni Cheruvu, Chittoor - APPCB" ...
 $ last_update  : chr [1:3317] "16-09-2024 21:00:00" "16-09-2024 21:00:00" "16-09-2024 21:00:00" "16-09-2024 21:00:00" ...
 $ latitude     : num [1:3317] 16.5 16.5 14.7 13.2 13.2 ...
 $ longitude    : num [1:3317] 80.5 80.5 77.6 79.1 79.1 ...
 $ pollutant_id : chr [1:3317] "SO2" "OZONE" "CO" "NO2" ...
 $ pollutant_min: num [1:3317] 15 10 29 8 3 NA NA NA 5 38 ...
 $ pollutant_max: num [1:3317] 19 43 48 9 4 NA NA NA 20 54 ...
 $ pollutant_avg: num [1:3317] 17 37 42 9 3 NA NA NA 12 52 ...
 - attr(*, "spec")=
  .. cols(
  ..   country = col_character(),
  ..   state = col_character(),
  ..   city = col_character(),
  ..   station = col_character(),
  ..   last_update = col_character(),
  ..   latitude = col_double(),
  ..   longitude = col_double(),
  ..   pollutant_id = col_character(),
  ..   pollutant_min = col_double(),
  ..   pollutant_max = col_double(),
  ..   pollutant_avg = col_double()
  .. )
 - attr(*, "problems")=<externalptr> 

Plots

Histogram of pollutant average levels

Boxplot comparing pollutant levels across states

Scatter plot of pollutant levels by latitude

---
title: "Air Quality Dashboard (Assignment2)"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    theme: journal
    social: menu
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(readr)
library(dplyr)
library(ggplot2)

# Load the dataset
data <- read_csv("Air Quality Index.csv")
```

## Overview {.tabset}
### Overview 
```{r}
# Display summary of dataset
summary(data)
```

### structure 
```{r}
str(data)
```

## Plots {.tabset}
### Histogram of pollutant average levels
```{r}
# Histogram of pollutant average levels
ggplot(data, aes(x = pollutant_avg)) + 
  geom_histogram(binwidth = 5, fill = 'skyblue', color = 'black') +
  labs(title = "Distribution of Pollutant Levels", x = "Pollutant Average", y="Frequency")

```

### Boxplot comparing pollutant levels across states

```{r}
# Boxplot comparing pollutant levels across states
ggplot(data, aes(x = state, y = pollutant_avg)) +
  geom_boxplot(fill = 'lightgreen') +
  labs(title = "Boxplot of Pollutant Levels by State", x = "State", y = "Pollutant Average") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

```

### Scatter plot of pollutant levels by latitude
```{r}
# Scatter plot of pollutant levels by latitude
ggplot(data, aes(x = latitude, y = pollutant_avg)) +
  geom_point(color = 'red') +
  labs(title = "Scatter Plot of Pollutant Levels by Latitude", x = "Latitude", y = "Pollutant Average")

```