This analysis explores the U.S. NOAA Storm Database to determine which weather events are most harmful to population health and which have the greatest economic consequences. Population health impact is measured using fatalities and injuries, while economic consequences are measured using property and crop damage. The results show that tornadoes are the most harmful to population health, while floods and hurricanes cause the greatest economic damage.
library(dplyr)
library(ggplot2)
if(!file.exists("StormData.csv.bz2")) {
download.file(
"https://d396qusza40orc.cloudfront.net/repdata/data/StormData.csv.bz2",
"StormData.csv.bz2"
)
}
data <- read.csv("StormData.csv.bz2", stringsAsFactors = FALSE)
## Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,
## : EOF within quoted string
storm <- data[, c("EVTYPE","FATALITIES","INJURIES","PROPDMG","PROPDMGEXP","CROPDMG","CROPDMGEXP")]
convert_exp <- function(exp) {
if (exp %in% c("H","h")) return(1e2)
if (exp %in% c("K","k")) return(1e3)
if (exp %in% c("M","m")) return(1e6)
if (exp %in% c("B","b")) return(1e9)
return(1)
}
storm$PROP_MULT <- sapply(storm$PROPDMGEXP, convert_exp)
storm$CROP_MULT <- sapply(storm$CROPDMGEXP, convert_exp)
storm$PROP_TOTAL <- storm$PROPDMG * storm$PROP_MULT
storm$CROP_TOTAL <- storm$CROPDMG * storm$CROP_MULT
health <- storm %>%
group_by(EVTYPE) %>%
summarise(
fatalities = sum(FATALITIES, na.rm = TRUE),
injuries = sum(INJURIES, na.rm = TRUE)
) %>%
mutate(total_health = fatalities + injuries) %>%
arrange(desc(total_health))
economic <- storm %>%
group_by(EVTYPE) %>%
summarise(
property = sum(PROP_TOTAL, na.rm = TRUE),
crop = sum(CROP_TOTAL, na.rm = TRUE)
) %>%
mutate(total_damage = property + crop) %>%
arrange(desc(total_damage))
top_health <- head(health, 10)
ggplot(top_health, aes(x = reorder(EVTYPE, total_health), y = total_health)) +
geom_bar(stat = "identity", fill = "steelblue") +
coord_flip() +
labs(
title = "Top 10 Harmful Weather Events (Health Impact)",
x = "Event Type",
y = "Fatalities + Injuries"
)
Tornadoes are the most harmful events to population health.
top_economic <- head(economic, 10)
ggplot(top_economic, aes(x = reorder(EVTYPE, total_damage), y = total_damage/1e9)) +
geom_bar(stat = "identity", fill = "darkred") +
coord_flip() +
labs(
title = "Top 10 Weather Events (Economic Damage)",
x = "Event Type",
y = "Damage (Billion USD)"
)
Floods and hurricanes cause the greatest economic damage.
Tornadoes have the highest impact on human health, while floods and hurricanes cause the largest economic losses. These insights are useful for disaster preparedness and resource allocation.