This report analyzes the impact of severe weather events on public health and economy in the United States between 1950 and 2011. Using the NOAA Storm Database, we address two main questions: which events are most harmful to population health and which have the greatest economic consequences. Our analysis finds that Tornadoes are the leading cause of fatalities and injuries, while Floods cause the highest total economic damage across the country.
We start by reading the raw compressed CSV file directly. Due to the large size of the dataset, we cache this step.
if (!file.exists("repdata_data_StormData.csv.bz2")) {
download.url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(download.url, "repdata_data_StormData.csv.bz2")
}
stormData <- read.csv("repdata_data_StormData.csv.bz2")
To find the most harmful events for population health, we aggregate the total number of fatalities and injuries by event type
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.3
health_impact <- stormData %>%
group_by(EVTYPE) %>%
summarize(Total_Fatalities = sum(FATALITIES),
Total_Injuries = sum(INJURIES)) %>%
mutate(Total_Impact = Total_Fatalities + Total_Injuries) %>%
arrange(desc(Total_Impact))
### Select top 10 for plotting
top_health <- head(health_impact, 10)
Economic consequences are stored in two parts: a coefficient (PROPDMG, CROPDMG) and an exponent multiplier (PROPDMGEXP, CROPDMGEXP). We need to convert symbols like ‘K’ (thousands), ‘M’ (millions), and ‘B’ (billions) into numeric values to calculate the total cost.
# Define Conversion Function
convert_exp <- function(e) {
if (e %in% c('h', 'H')) return(100)
if (e %in% c('k', 'K')) return(1000)
if (e %in% c('m', 'M')) return(10^6)
if (e %in% c('b', 'B')) return(10^9)
return(1)
}
# Calculate The Loss Of Properties And The Loss Of Crops
stormData$prop_mult <- sapply(stormData$PROPDMGEXP, convert_exp)
stormData$crop_mult <- sapply(stormData$CROPDMGEXP, convert_exp)
library(dplyr)
econ_impact <- stormData %>%
mutate(Total_Cost = (PROPDMG * prop_mult) + (CROPDMG * crop_mult)) %>%
group_by(EVTYPE) %>%
summarize(Total_Damage = sum(Total_Cost)) %>%
arrange(desc(Total_Damage))
top_econ <- head(econ_impact, 10)
## Results
### 1. Most Harmful Events to Population Health
The following plot shows the top 10 weather events that caused the highest total number of fatalities and injuries.
``` r
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.3
ggplot(top_health, aes(x = reorder(EVTYPE, -Total_Impact), y = Total_Impact)) +
geom_bar(stat = "identity", fill = "red") +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = "Top 10 Most Harmful Weather Events",
x = "Event Type", y = "Total Fatalities and Injuries")
As shown in the figure, Tornadoes are by far the most dangerous event
type to population health in the US.
The plot below illustrates the top 10 events with the highest total economic damage (Property + Crops).
ggplot(top_econ, aes(x = reorder(EVTYPE, -Total_Damage), y = Total_Damage/10^9)) +
geom_bar(stat = "identity", fill = "blue") +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = "Top 10 Weather Events by Economic Damage",
x = "Event Type", y = "Total Damage (Billions of USD)")
Based on the analysis, Floods result in the greatest economic consequences, followed by Hurricanes/Typhoons and Tornadoes.