library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(pastecs)
## 
## Attaching package: 'pastecs'
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
setwd("~/Desktop/Capstone Data Sets ")
air_quality <-read_csv("air_quality.csv")
## Rows: 527132 Columns: 11
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (3): district_id, air_quality_category, sensor_status
## dbl  (7): pm25, pm10, no2, o3, co, synthetic_aqi, pollution_alert_flag
## dttm (1): timestamp
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#Clean Dataset
air_quality_clean <- air_quality %>%
    filter(!is.na(o3))
# Question 1: Use Approved Dataset
# air_quality.csv

#Question 2: Select some variables of interest and see if there is any obvious correlations using the COR command
# air_quality$o3 "Ozone" variable and # air_quality$co "Carbon Monoxide" variable and air_quality$no2

cor(air_quality_clean$o3,air_quality_clean$co)
## [1] 0.2792597
cor(air_quality_clean$o3,air_quality_clean$no2)
## [1] 0.2766292
cor(air_quality_clean$no2,air_quality_clean$co) #this has the strongest relationship
## [1] 0.5576262
#Question 3:Examine the same variables visually using the PAIRS command 

pairs(air_quality_clean[, c("o3", "co")])

#Question 4: Select two variables that seem correlated (positively or negatively) and examine them using PEARSON, SPEARMAN or KENDALL (depending on which is more appropriate)
cor(air_quality_clean$o3, air_quality_clean$co, method = "pearson")
## [1] 0.2792597
cor(air_quality_clean$o3, air_quality_clean$co, method = "spearman")
## [1] 0.346981
#Question 5: Explain your findings and justify your choice in selecting the correlation method
#The pearson model made the numbers a little too similar, the spearman model had a better correlation. The kendall model casused my new computer to crash so I would go with the spearman. 
#Question 6:publish to Rpubs and submit via CANVAS
  1. Use your approved data-set
  2. Select some variables of interest and see if there is any obvious correlations using the COR command
  3. Examine the same variables visually using the PAIRS command
  4. Select two variables that seem correlated (positively or negatively) and examine them using PEARSON, SPEARMAN or KENDALL (depending on which is more appropriate)
  5. Explain your findings and justify your choice in selecting the correlation method
  6. publish to Rpubs and submit via CANVAS