This analysis explores the NOAA Storm Database to determine which types of weather events are most harmful to population health and which cause the greatest economic damage. The dataset spans from 1950 to 2011. The analysis shows that tornadoes are the most harmful event type in terms of injuries and overall harm, while excessive heat leads in fatalities. Floods and hurricanes contribute the most to economic damage. These insights can help governments prioritize disaster preparedness.
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.3
##
## 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.5.3
# Load data
data <- read.csv("repdata_data_StormData.csv.bz2", stringsAsFactors = FALSE)
# Clean EVTYPE
data$EVTYPE <- toupper(trimws(data$EVTYPE))
# -----------------------------
# HEALTH IMPACT
# -----------------------------
health_data <- data %>%
group_by(EVTYPE) %>%
summarise(
fatalities = sum(FATALITIES, na.rm = TRUE),
injuries = sum(INJURIES, na.rm = TRUE)
)
health_data$total_harm <- health_data$fatalities + health_data$injuries
health_top <- health_data %>%
arrange(desc(total_harm)) %>%
slice(1:10)
# -----------------------------
# ECONOMIC IMPACT
# -----------------------------
convert_exp <- function(exp) {
exp <- toupper(trimws(exp))
if (exp == "H") return(1e2)
if (exp == "K") return(1e3)
if (exp == "M") return(1e6)
if (exp == "B") return(1e9)
return(1)
}
data$prop_mult <- sapply(data$PROPDMGEXP, convert_exp)
data$crop_mult <- sapply(data$CROPDMGEXP, convert_exp)
data$prop_damage <- data$PROPDMG * data$prop_mult
data$crop_damage <- data$CROPDMG * data$crop_mult
economic_data <- data %>%
group_by(EVTYPE) %>%
summarise(total_damage = sum(prop_damage + crop_damage, na.rm = TRUE))
economic_top <- economic_data %>%
arrange(desc(total_damage)) %>%
slice(1:10)
ggplot(health_top, aes(x = reorder(EVTYPE, total_harm), y = total_harm)) +
geom_bar(stat = "identity", fill = "steelblue") +
coord_flip() +
labs(title = "Top 10 Events Harmful to Population Health",
x = "Event Type", y = "Total Harm (Fatalities + Injuries)")
Tornadoes are the most harmful events overall, followed by excessive heat and floods.
ggplot(economic_top, aes(x = reorder(EVTYPE, total_damage), y = total_damage/1e9)) +
geom_bar(stat = "identity", fill = "darkred") +
coord_flip() +
labs(title = "Top 10 Events Causing Economic Damage",
x = "Event Type", y = "Total Damage (Billions USD)")
Floods and hurricanes are the leading causes of economic damage.