Packages:

library(readr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.1

Data:

Sources:

tornadoes = read.csv('tornadoes.csv', skip = 1)
temp = read.csv('global_temp.csv', skip = 4)
hurricanes = read.csv('hurricanes.csv')

Data Inspection:

head(hurricanes)
##   Year Named.Storms Named.Storm.Days Hurricanes Hurricanes.Days
## 1 1980           73           367.25         43          143.75
## 2 1981           82           363.75         45          125.75
## 3 1982           81           428.75         46          162.25
## 4 1983           79           369.50         42          150.00
## 5 1984           93           439.00         47          160.25
## 6 1985           95           455.25         51          163.50
##   Cat..3..Hurricanes Cat..3..Hurricanes.Days Accumulated.Cyclone.Energy
## 1                 19                   30.25                      638.0
## 2                 15                   19.50                      554.7
## 3                 21                   37.75                      709.2
## 4                 21                   47.25                      680.0
## 5                 20                   41.25                      726.2
## 6                 24                   27.75                      717.8
head(temp)
##     Date Anomaly
## 1 198001    0.37
## 2 198002    0.46
## 3 198003    0.35
## 4 198004    0.35
## 5 198005    0.39
## 6 198006    0.27
head(tornadoes)
##     Date Tornadoes Fatalities
## 1 195001         7          1
## 2 195002        20         45
## 3 195003        21          1
## 4 195004        15         12
## 5 195005        61          2
## 6 195006        28          6

Cleaning Tornadoes:

tornadoes = tornadoes %>%
  mutate(Month = as.integer(substr(as.character(Date), nchar(as.character(Date)) - 1, nchar(as.character(Date)))), 
         Year = as.integer(substr(as.character(Date), 1, nchar(as.character(Date)) - 2)),
         Tornadoes = as.double(gsub("[^0-9]", "", Tornadoes))) %>%
  select(-Date)

Cleaning Temp:

temp = temp %>%
  mutate(Month = as.integer(substr(as.character(Date), nchar(as.character(Date)) - 1, nchar(as.character(Date)))), 
         Year = as.integer(substr(as.character(Date), 1, nchar(as.character(Date)) - 2))) %>%
  select(-Date)

Aggregating Tornadoes:

tornadoes_by_year = tornadoes %>%
  group_by(Year) %>%
  summarise(Tornadoes = sum(Tornadoes), 
            Tornado_Fatalities = sum(Fatalities)) %>%
  filter(Year > 1979)

Aggregating Temp:

temp_by_year = temp %>%
  group_by(Year) %>%
  summarise(`Average Anomaly (C)` = mean(Anomaly)) %>%
  mutate(`Average Anomaly (F)` = 1.8 * `Average Anomaly (C)` + 32)

Joining the data:

df = merge(temp_by_year, merge(tornadoes_by_year, hurricanes, on = 'Year'), on = 'Year')

df = df %>%
  filter(Year > 1997) %>%
  rename(Cat_3_plus_hurricanes = Cat..3..Hurricanes) %>%
  mutate(proportion_cat_3 = Cat_3_plus_hurricanes / Hurricanes, avg_cyclonic_energy = Accumulated.Cyclone.Energy / Hurricanes)

Plot: Yearly Average Temperature Anomaly (Fahrenheit)

ggplot(df, aes(x = Year, y = `Average Anomaly (F)`)) + 
  geom_line() +
  labs(title = 'Yearly Temperature Anomaly Average (F)')

Plot: Yearly Tornado Counts

ggplot(df, aes(x = Year, y = Tornadoes)) + 
  geom_line() +
  labs(title = 'Yearly Tornado Count')

Plot: Yearly Tornado Fatality Counts

ggplot(df, aes(x = Year, y = Tornado_Fatalities)) + 
  geom_line() +
  labs(y = 'Tornado-Related Fatalities', title = 'Yearly Tornado-Related Fatality Count')

Plot: Hurricanes Per Year

ggplot(df, aes(x = Year, y = Hurricanes)) + 
  geom_line() +
  labs(title = 'Yearly Hurricane Count')

Plot: Cat 3+ Hurricanes per Year

ggplot(df, aes(x = Year, y = Cat_3_plus_hurricanes)) + 
  geom_line() +
  labs(y = 'Category 3+ Hurricanes', title = 'Yearly Category 3+ Hurricane Count')

Plot: Proportion Cat 3+ Hurricanes

ggplot(df, aes(x = Year, y = proportion_cat_3)) + 
  geom_line() +
  labs(y = 'Proportion Category 3+ of Total Hurricanes', title = 'Yearly Proportion Category 3+ of Total Hurricanes')

Plot: Yearly Average Cyclonic Energy

ggplot(df, aes(x = Year, y = avg_cyclonic_energy)) + 
  geom_line() +
  labs(y = 'Average Cyclonic Energy', title = 'Yearly Average Cyclonic Energy')

Plot: Yearly Average Temperature with Yearly Tornado Count

scale = (mean(df$`Average Anomaly (F)`)/mean(df$Tornadoes))

ggplot(df, aes(x = Year)) + 
  geom_line(aes(y = Tornadoes, color = 'Tornadoes')) +
  geom_line(aes(y = `Average Anomaly (F)` / scale, color = 'Average Anomaly (F)')) +
  scale_y_continuous(
    name = "Tornadoes",
    sec.axis = sec_axis(~.*scale, name = "Average Anomaly (F)")
  ) +
  labs(color = "Key", title = 'Comparing Yearly Average Temperature Anomaly \n and Yearly Tornado Count')

Plot: Yearly Average Temperature with Yearly Hurricane Count

scale = (mean(df$`Average Anomaly (F)`)/mean(df$Hurricanes))

ggplot(df, aes(x = Year)) + 
  geom_line(aes(y = Hurricanes, color = 'Hurricanes')) +
  geom_line(aes(y = `Average Anomaly (F)` / scale, color = 'Average Anomaly (F)')) +
  scale_y_continuous(
    name = "Hurricanes",
    sec.axis = sec_axis(~.*scale, name = "Average Anomaly (F)")
  ) +
  labs(color = "Key", title = 'Comparing Yearly Average Temperature Anomaly \n and Yearly Hurricane Count')

Plot: Yearly Average Temperature with Yearly Category 3 + Hurricane Count

scale = (mean(df$`Average Anomaly (F)`)/mean(df$Cat_3_plus_hurricanes))

ggplot(df, aes(x = Year)) + 
  geom_line(aes(y = Cat_3_plus_hurricanes, color = 'Category 3+ Hurricanes')) +
  geom_line(aes(y = `Average Anomaly (F)` / scale, color = 'Average Anomaly (F)')) +
  scale_y_continuous(
    name = "Category 3+ Hurricanes",
    sec.axis = sec_axis(~.*scale, name = "Average Anomaly (F)")
  ) +
  labs(color = "Key", title = 'Comparing Yearly Average Temperature and \n Yearly Category 3+ Hurricane Count')

Plot: Yearly Average Temperature with Yearly Proportion of Hurricanes Rated Cat 3+

scale = (mean(df$`Average Anomaly (F)`)/mean(df$proportion_cat_3))

ggplot(df, aes(x = Year)) + 
  geom_line(aes(y = proportion_cat_3, color = 'Proportion Category 3+')) +
  geom_line(aes(y = `Average Anomaly (F)` / scale, color = 'Average Anomaly (F)')) +
  scale_y_continuous(
    name = "Proportion of Hurricanes Rated Category 3+",
    sec.axis = sec_axis(~.*scale, name = "Average Anomaly (F)")
  ) +
  labs(color = "Key", title = 'Comparing Yearly Average Temperature Anomaly \n and Yearly Proportion of Hurricanes Rated Category 3+')