This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclimate data.Rmd
187 lines (146 loc) · 4.17 KB
/
climate data.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
title: "313 project temp"
author: "Yara Ghabra 1006336056"
date: "2022-10-31"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
getwd()
library(tidyverse)
```
```{r}
library(tidyverse)
library(lubridate)
temp <- read.csv("/Users/gracewalkermitchell/Desktop/EEB313/GroupB/CALIFORNIA.csv")
temp_annual<- temp %>%
select(STATION, NAME, DATE, PRCP, TMAX, TMIN) %>%
group_by(DATE) %>%
filter(!is.na(TMAX), !is.na(TMIN), !is.na(PRCP)) %>%
summarise(avg_prcp= mean(PRCP), avg_tmax= mean(TMAX), avg_tmin= mean(TMIN))
temp_annual
```
```{r}
#LOUISIANA
Louisiana <- read.csv("/Users/gracewalkermitchell/Desktop/EEB313/GroupB/Louisiana metric.csv")
lou_temp_monthly<- Louisiana %>%
select(STATION, NAME, DATE, PRCP, TMAX, TMIN) %>%
group_by(DATE) %>%
filter(!is.na(TMAX), !is.na(TMIN), !is.na(PRCP)) %>%
mutate(month= month(DATE), year= year(DATE), day=yday(DATE))
lou_temp_month<- lou_temp_monthly %>%
group_by(year, month) %>%
filter(!is.na(TMAX), !is.na(TMIN), !is.na(PRCP)) %>%
summarise(avg_prcp= mean(PRCP), avg_tmax= mean(TMAX), avg_tmin= mean(TMIN)) %>%
mutate(year=as.factor(year), month=as.factor(month))
lou_temp_month
lou_temp_month %>%
ggplot(aes(x=month, y=avg_tmax, colour=year))+
geom_point()+
geom_line(mapping=aes(group=year))
```
```{r}
#LOUISIANA SUMMER TEMP MAXES
lou_summer_max<-lou_temp_monthly %>%
group_by(year, month) %>%
mutate(avg_temp=mean(TMAX)) %>%
filter(5<=month & month<=10) %>%
select(month, year, avg_temp) %>%
unique()
lou_summer_max$year<-as.factor(lou_summer_max$year)
ggplot(data=lou_summer_max, aes(month, avg_temp, colour=year))+
geom_point()+
geom_line(mapping=aes(group=year))
```
```{r}
#CALIFORNIA
library("lubridate")
Cali <- read.csv("CALIFORNIA.csv")
cali_temp_monthly<- Cali %>%
select(STATION, NAME, DATE, PRCP, TMAX, TMIN) %>%
group_by(DATE) %>%
filter(!is.na(TMAX), !is.na(TMIN), !is.na(PRCP)) %>%
mutate(month= month(DATE), year= year(DATE), day=yday(DATE))
cali_temp_month<- cali_temp_monthly %>%
group_by(year, month) %>%
filter(!is.na(TMAX), !is.na(TMIN), !is.na(PRCP)) %>%
summarise(avg_prcp= mean(PRCP), avg_tmax= mean(TMAX), avg_tmin= mean(TMIN)) %>%
mutate(year=as.factor(year), month=as.factor(month))
cali_temp_month
cali_temp_month %>%
ggplot(aes(x=month, y=avg_tmax, colour=year))+
geom_point()+
geom_line(mapping=aes(group=year))
```
```{r}
#CALIFORNIA SUMMER TEMP MAXES
cali_summer_max<-cali_temp_monthly %>%
group_by(year, month) %>%
mutate(avg_temp=mean(TMAX)) %>%
filter(5<=month & month<=10) %>%
select(month, year, avg_temp) %>%
unique()
cali_summer_max$year<-as.factor(cali_summer_max$year)
ggplot(data=cali_summer_max, aes(month, avg_temp, colour=year))+
geom_point()+
geom_line(mapping=aes(group=year))
```
###Precipitation
```{r}
#CALIFORNIA
cali_precip_yearly<- cali_temp_monthly %>%
group_by(year) %>%
filter(!is.na(PRCP)) %>%
mutate(year=as.factor(year), avg.precip=mean(PRCP)) %>%
select(year, avg.precip) %>%
unique()
cali_precip_yearly
```
```{r}
cali_precip_yearly %>%
ggplot(aes(x=year, y=avg.precip))+
geom_col()
```
```{r}
#LOUISIANA
lou_precip_yearly<- lou_temp_monthly%>%
group_by(year) %>%
filter(!is.na(PRCP)) %>%
mutate(year=as.factor(year), avg.precip=mean(PRCP)) %>%
select(year, avg.precip) %>%
unique()
lou_precip_yearly
```
```{r}
lou_precip_yearly %>%
ggplot(aes(x=year, y=avg.precip))+
geom_col()
#much less variable than california
```
###are summers getting drier? could look at dates of rain throughout the years
```{r}
#CALIFORNIA dates of rain - year round
cali_temp_monthly %>%
ggplot(aes(day, PRCP))+
geom_col()+
facet_wrap(~year)
```
```{r}
#are summers getting drier? dates of rain between April and September
cali_temp_monthly %>%
filter(month>=4 & month<=9) %>%
ggplot(aes(day, PRCP))+
geom_col()+
facet_wrap(~year)
```
```{r}
#mean yearly summer precipitation in California
cali_temp_monthly %>%
filter(month>=4 & month<=9) %>%
group_by(year) %>%
summarise(mean_precip=mean(PRCP)) %>%
ggplot(aes(year, mean_precip))+
geom_point()+
geom_smooth()+
theme_classic()
```