forked from Env-Data-Sci-FA23/Week-2-Debugging-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorms_Ghamedi.Rmd
101 lines (74 loc) · 2.1 KB
/
storms_Ghamedi.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
---
title: "storms_Ghamedi"
author: "OGhamedi"
date: "2023-10-27"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
source("Setup.R")
```
# Answrering the question: "How have storms changed over time?"
*download .csv of storms*
```{r}
storms_raw <- read_csv("data/storms.csv")
```
# Explore data
```{r}
glimpse(storms_raw)
```
# Organizes data in by Year and Catagory -- all storms in bar plot
```{r}
# Filter out rows with NA in the "category" column
storms_filt <- storms_raw %>%
filter(!is.na(category))
# Create a bar plot
ggplot(storms_filt, aes(x = factor(year), fill = factor(category))) +
geom_bar() +
labs(x = "Year", y = "Count") +
ggtitle("Bar Plot of Category Count by Year (Excluding NA Values)") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
```
# Visualizing storm status by year in bar plot
```{r}
# Create a bar plot of "status" by year
ggplot(storms_raw, aes(x = factor(year), fill = factor(status))) +
geom_bar() +
labs(x = "Year", y = "Count") +
ggtitle("Bar Plot of Status by Year") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
```
# Re-visulaizing the year vs. status as a line plot
```{r}
# Create a line chart of "status" over time
ggplot(storms_raw, aes(x = year, group = status, color = status)) +
geom_line(stat = "count") +
labs(x = "Year", y = "Count") +
ggtitle("Trend of Storm Status Over Time") +
scale_color_discrete(name = "Status") +
theme(legend.position = "top")
```
# Looking at mean wind values by year
```{r}
storm_wind <- storms_raw %>%
group_by(year) %>%
summarise(mean_wind = mean(wind, na.rm = TRUE))
```
# Visualise the relationship
```{r}
storm_wind %>%
ggplot(aes(x = year, y = mean_wind)) +
geom_line()
```
# Histogram of all hurricanes over time w/ density plot
```{r}
# Filter out rows with NA in the "category" column
hurr_filt <- storms_raw %>%
filter(status == "hurricane") %>%
group_by(year)
ggplot(hurr_filt, aes(x=year)) +
geom_histogram(aes(y=..density..), colour="black", fill="white")+
geom_density(alpha=.2, fill="#FF6666")
```