This report analyzes the impact of severe weather events on public health and the economy using the U.S. National Weather Service Storm Data.
if (!require("data.table")) install.packages("data.table", repos="https://cloud.r-project.org")
## Loading required package: data.table
if (!require("R.utils")) install.packages("R.utils", repos="https://cloud.r-project.org")
## Loading required package: R.utils
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.27.1 (2025-05-02 21:00:05 UTC) successfully loaded. See ?R.oo for help.
##
## Attaching package: 'R.oo'
## The following object is masked from 'package:R.methodsS3':
##
## throw
## The following objects are masked from 'package:methods':
##
## getClasses, getMethods
## The following objects are masked from 'package:base':
##
## attach, detach, load, save
## R.utils v2.13.0 (2025-02-24 21:20:02 UTC) successfully loaded. See ?R.utils for help.
##
## Attaching package: 'R.utils'
## The following object is masked from 'package:utils':
##
## timestamp
## The following objects are masked from 'package:base':
##
## cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
library(data.table)
library(R.utils)
if (!file.exists("storm.csv")) {
bunzip2("repdata_data_StormData.csv.bz2", destname = "storm.csv", remove = FALSE)
}
storm_data <- fread("storm.csv")
health_data <- storm_data[, .(
FATALITIES = sum(FATALITIES, na.rm = TRUE),
INJURIES = sum(INJURIES, na.rm = TRUE)
), by = EVTYPE]
health_data[, total_harm := FATALITIES + INJURIES]
setorder(health_data, -total_harm)
head(health_data, 10)
## EVTYPE FATALITIES INJURIES total_harm
## <char> <num> <num> <num>
## 1: TORNADO 5633 91346 96979
## 2: EXCESSIVE HEAT 1903 6525 8428
## 3: TSTM WIND 504 6957 7461
## 4: FLOOD 470 6789 7259
## 5: LIGHTNING 816 5230 6046
## 6: HEAT 937 2100 3037
## 7: FLASH FLOOD 978 1777 2755
## 8: ICE STORM 89 1975 2064
## 9: THUNDERSTORM WIND 133 1488 1621
## 10: WINTER STORM 206 1321 1527
This analysis calculates total fatalities and injuries for each event
type.
A combined metric total_harm is used to identify the
most dangerous events.
top_health <- head(health_data, 10)
barplot(top_health$total_harm,
names.arg = top_health$EVTYPE,
las = 2,
col = "red",
main = "Top 10 Most Harmful Events",
ylab = "Total Harm")
convert_exp <- function(x) {
ifelse(x == "K", 1e3,
ifelse(x == "M", 1e6,
ifelse(x == "B", 1e9, 1)))
}
storm_data[, PROPDMGEXP := toupper(PROPDMGEXP)]
storm_data[, CROPDMGEXP := toupper(CROPDMGEXP)]
storm_data[, prop_damage := PROPDMG * convert_exp(PROPDMGEXP)]
storm_data[, crop_damage := CROPDMG * convert_exp(CROPDMGEXP)]
storm_data[, total_damage := prop_damage + crop_damage]
econ_data <- storm_data[, .(
total_damage = sum(total_damage, na.rm = TRUE)
), by = EVTYPE]
setorder(econ_data, -total_damage)
head(econ_data, 10)
## EVTYPE total_damage
## <char> <num>
## 1: FLOOD 150319678257
## 2: HURRICANE/TYPHOON 71913712800
## 3: TORNADO 57352114049
## 4: STORM SURGE 43323541000
## 5: HAIL 18758221521
## 6: FLASH FLOOD 17562129167
## 7: DROUGHT 15018672000
## 8: HURRICANE 14610229010
## 9: RIVER FLOOD 10148404500
## 10: ICE STORM 8967041360
Economic damage is calculated by combining property and crop
damage.
Damage multipliers (K, M, B) are converted into numeric values.
top_econ <- head(econ_data, 10)
barplot(top_econ$total_damage,
names.arg = top_econ$EVTYPE,
las = 2,
col = "blue",
main = "Top 10 Economic Damage Events",
ylab = "Total Damage")
This analysis helps identify the most severe weather events for better preparedness.