Introduction

This report presents an analysis of the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. The objective is to explore major storms and weather events in the United States, focusing on their public health and economic impacts. This analysis covers events from 1950 through November 2011.

Data Processing

The data was loaded and processed using R. The following code chunk shows how the storm data was read and prepared for analysis:

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(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(tidyr)
library(ggplot2)  # Load ggplot2 for plotting
data_path <- "repdata_data_StormData.csv.bz2"
storm_data <- read_csv(file = bzfile(data_path)) %>%
  mutate(
    BGN_DATE = as.Date(BGN_DATE, format = "%Y-%m-%d"),
    EVTYPE = tolower(EVTYPE)
  )
## Rows: 902297 Columns: 37
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (18): BGN_DATE, BGN_TIME, TIME_ZONE, COUNTYNAME, STATE, EVTYPE, BGN_AZI,...
## dbl (18): STATE__, COUNTY, BGN_RANGE, COUNTY_END, END_RANGE, LENGTH, WIDTH, ...
## lgl  (1): COUNTYENDN
## 
## ℹ 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.
storm_data <- storm_data %>%
  filter(year(BGN_DATE) >= 1996) %>%
  drop_na()

# Calculate the health impact data frame
health_impact <- storm_data %>%
  group_by(EVTYPE) %>%
  summarise(Total_Fatalities = sum(FATALITIES), Total_Injuries = sum(INJURIES)) %>%
  arrange(desc(Total_Fatalities + Total_Injuries))

# Plotting health impact
health_plot <- ggplot(health_impact, aes(x=reorder(EVTYPE, -(Total_Fatalities + Total_Injuries)), y=Total_Fatalities + Total_Injuries, fill=EVTYPE)) +
  geom_col(show.legend = FALSE) +
  labs(title="Total Health Impact by Event Type", x="Event Type", y="Total Health Impact (Fatalities + Injuries)") +
  theme(axis.text.x = element_text(angle=45, hjust=1))

# Save the plot as an image
plot_path <- "health_impact_plot.png"
ggsave(plot_path, plot = health_plot, width = 10, height = 6, dpi = 300)

# Use Markdown to include the image
cat("![](", plot_path, ")\n")
## ![]( health_impact_plot.png )
# Calculate economic impact
economic_impact <- storm_data %>%
  group_by(EVTYPE) %>%
  summarise(Total_Damages = sum(PROPDMG + CROPDMG)) %>%
  arrange(desc(Total_Damages))

knitr::kable(economic_impact)
EVTYPE Total_Damages
# Plotting economic impact
ggplot(economic_impact, aes(x=reorder(EVTYPE, -Total_Damages), y=Total_Damages, fill=EVTYPE)) +
  geom_col(show.legend = FALSE) +
  labs(title="Total Economic Impact by Event Type", x="Event Type", y="Total Damages") +
  theme(axis.text.x = element_text(angle=45, hjust=1))