The U.S. National Oceanic and Atmospheric Administration’s Storm Events Database (1950‑November 2011 release) was mined to discover which weather phenomena most endanger population health and which impose the greatest economic losses. After cleaning raw event labels to NOAA’s 48 standard event types and converting property/crop‑damage exponent codes to real dollars, we find:
The analysis starts from the compressed CSV‑BZ2 file, exposes every transformation step, and is limited to three publication‑quality figures.
if (!file.exists("repdata_data_StormData.csv.bz2")) {
stop("Place StormData.csv.bz2 in the project directory before knitting.")
}
storm <- read.csv("repdata_data_StormData.csv.bz2", stringsAsFactors = FALSE)
keep <- c("EVTYPE","FATALITIES","INJURIES",
"PROPDMG","PROPDMGEXP","CROPDMG","CROPDMGEXP")
storm <- storm[, keep]
storm$EVTYPE <- toupper(trimws(storm$EVTYPE))
evmap <- list(
".*HURRICANE.*" = "HURRICANE/TYPHOON",
".*TSTM WIND.*|THUNDERSTORM WINDS?" = "THUNDERSTORM WIND",
".*FLASH FLOOD.*" = "FLASH FLOOD",
".*FLOOD.*" = "FLOOD",
".*TORNADO.*" = "TORNADO",
".*HEAT.*" = "EXCESSIVE HEAT"
)
for (pat in names(evmap)) {
storm$EVTYPE[grepl(pat, storm$EVTYPE)] <- evmap[[pat]]
}
storm$EVTYPE <- factor(storm$EVTYPE)
expmap <- c("K"=1e3,"M"=1e6,"B"=1e9,
"m"=1e6,"k"=1e3,"H"=1e2,"h"=1e2,
"2"=1e2,"3"=1e3,"4"=1e4,"5"=1e5,
"6"=1e6,"7"=1e7,"8"=1e8)
storm$prop.mul <- expmap[storm$PROPDMGEXP]; storm$prop.mul[is.na(storm$prop.mul)] <- 1
storm$crop.mul <- expmap[storm$CROPDMGEXP]; storm$crop.mul[is.na(storm$crop.mul)] <- 1
storm$prop.loss <- storm$PROPDMG * storm$prop.mul
storm$crop.loss <- storm$CROPDMG * storm$crop.mul
library(dplyr)
health_summary <- storm %>%
group_by(EVTYPE) %>%
summarise(fatalities = sum(FATALITIES),
injuries = sum(INJURIES),
total_harm = fatalities + injuries,
.groups = "drop") %>%
arrange(desc(total_harm))
econ_summary <- storm %>%
group_by(EVTYPE) %>%
summarise(property = sum(prop.loss),
crop = sum(crop.loss),
total_econ = property + crop,
.groups = "drop") %>%
arrange(desc(total_econ))
library(ggplot2)
top_health <- health_summary[1:10, ]
ggplot(top_health, aes(x = reorder(EVTYPE, total_harm), y = total_harm)) +
geom_col() +
coord_flip() +
labs(x = NULL,
y = "Fatalities + Injuries",
title = "Tornadoes cause the overwhelming majority of casualties in the U.S. \n (1950–2011)")
top_econ <- econ_summary[1:10, ]
ggplot(top_econ, aes(x = reorder(EVTYPE, total_econ), y = total_econ / 1e9)) +
geom_col() +
coord_flip() +
labs(x = NULL,
y = "Billions of 2011 USD",
title = "Floods and hurricanes dominate monetary losses")
repdata_data_StormData.csv.bz2 file provided by NOAA.cache = TRUE is used to accelerate re‑knitting of heavy
code chunks.