-
Notifications
You must be signed in to change notification settings - Fork 0
/
R-Air.rmd
150 lines (125 loc) · 4.9 KB
/
R-Air.rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
---
title: "Boulder Ozone Exploratory Analysis"
author: "Gabriella Brinkley"
date: "8/18/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(stats)
library(ggplot2)
library(tidyverse)
library(trend)
```
# Loading the data
### Data from EPA
### Location BR= Boulder Res SBC= South Boulder Creek
```{r}
ozone21<- read.csv("boulder_ozone_21.csv") #BR
ozone20<- read.csv("boulder_ozone_20.csv") #BR
ozone19<- read.csv("boulder_ozone_19.csv") #BR
ozone18<- read.csv("boulder_ozone_18.csv") #BR
ozone17<- read.csv("boulder_ozone_17.csv") #BR
ozone16<- read.csv("boulder_ozone_16.csv") #BR
ozone15<- read.csv("boulder_ozone_15.csv") #SBC
ozone14<- read.csv("boulder_ozone_14.csv") #SBC
ozone13<- read.csv("boulder_ozone_13.csv") #SBC
ozone12<- read.csv("boulder_ozone_12.csv") #SBC
ozone11<- read.csv("boulder_ozone_11.csv") #SBC
ozone10<- read.csv("boulder_ozone_10.csv") #SBC
ozone99<- read.csv("boulder_ozone_99.csv") #SBC
view(ozone13)
```
# Ozone stats summary for each year
```{r}
## 1999
summary(ozone99$Daily.Max.8.hour.Ozone.Concentration)
## 2010
summary(ozone10$Daily.Max.8.hour.Ozone.Concentration)
## 2011
summary(ozone11$Daily.Max.8.hour.Ozone.Concentration)
## 2012
summary(ozone12$Daily.Max.8.hour.Ozone.Concentration)
## 2013
summary(ozone13$Daily.Max.8.hour.Ozone.Concentration)
## 2014
summary(ozone14$Daily.Max.8.hour.Ozone.Concentration)
## 2015
summary(ozone15$Daily.Max.8.hour.Ozone.Concentration)
## 2016
summary(ozone16$Daily.Max.8.hour.Ozone.Concentration)
## 2017
summary(ozone17$Daily.Max.8.hour.Ozone.Concentration)
## 2018
summary(ozone18$Daily.Max.8.hour.Ozone.Concentration)
## 2019
summary(ozone19$Daily.Max.8.hour.Ozone.Concentration)
## 2020
summary(ozone20$Daily.Max.8.hour.Ozone.Concentration)
## 2021
summary(ozone21$Daily.Max.8.hour.Ozone.Concentration)
```
# Distribution of the data
```{r}
hist(ozone20$Daily.Max.8.hour.Ozone.Concentration)
## Most years show fairly normally distributed data.
```
# Find which date the max ozone value occurs at in each year
```{r}
which.max(ozone99$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone10$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone11$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone12$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone13$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone14$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone15$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone16$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone17$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone18$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone19$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone20$Daily.Max.8.hour.Ozone.Concentration)
which.max(ozone21$Daily.Max.8.hour.Ozone.Concentration)
## will compare the month of July for each year, because that is when the highest values occur.
```
# Ozone and AQI over time in 2020
```{r}
ggplot(ozone20, aes(x= Day, y=Daily.Max.8.hour.Ozone.Concentration ))+
geom_smooth()+
labs(x="Day of the year in 2020", y="Max 8 hour Ozone (ppm)")+
theme_bw()
ggplot(ozone20, aes(x= Day, y=DAILY_AQI_VALUE ))+
geom_smooth()+
labs(x="Day of the year in 2020", y="AQI")+
theme_bw()
```
# Ozone and AQI correlation
```{r}
cor.test(ozone20$Daily.Max.8.hour.Ozone.Concentration,ozone20$DAILY_AQI_VALUE)
## The ozone concentration strongly correlates to AQI as expected.
```
# Filtering and visualizing the data
```{r}
all<-rbind(ozone10, ozone11, ozone12, ozone13, ozone14, ozone15, ozone16, ozone17,ozone18,ozone19,ozone20, ozone21)
## Filtering only July data
all_July<-all%>%filter(all$Month=="July")
## Ozone Concentration in July over 10 years (2010-2020)
ggplot(all_July, aes(x=Day, y= Daily.Max.8.hour.Ozone.Concentration))+
geom_smooth()+
labs(y="Daily Max Ozone Concentration (ppm) in July", x= "Day (Julian)")+
theme_bw()
```
# Statistical tests for Ozone in the month of July
```{r}
July20<-ozone20%>%filter(ozone20$Month=="July")
July10<-ozone10%>%filter(ozone10$Month=="July")
July99<-ozone99%>%filter(ozone99$Month=="July")
sens.slope(all_July$DAILY_AQI_VALUE)
sens.slope(all_July$Daily.Max.8.hour.Ozone.Concentration)
t.test(ozone20$Daily.Max.8.hour.Ozone.Concentration,ozone10$Daily.Max.8.hour.Ozone.Concentration) ##overall mean ozone values are not significantly different in 2010 and 2020
t.test(July20$Daily.Max.8.hour.Ozone.Concentration,July10$Daily.Max.8.hour.Ozone.Concentration) ## mean ozone values of July 2020 and 2010 are not significantly different.
t.test(ozone99$Daily.Max.8.hour.Ozone.Concentration,ozone20$Daily.Max.8.hour.Ozone.Concentration) ## overall mean ozone values are significantly different
t.test(July99$Daily.Max.8.hour.Ozone.Concentration,July20$Daily.Max.8.hour.Ozone.Concentration)
## mean values in July are not significantly different
```