This analysis uses the NOAA Storm Database to determine which severe weather events have had the greatest effects on population health and the economy in the United States. Population-health impact is measured as the combined number of fatalities and injuries. Economic impact is measured as the sum of reported property and crop damage after the damage exponent codes are converted into dollar multipliers. Event names are converted to uppercase and extra spaces are removed before totals are calculated. The results show that tornadoes have caused the greatest combined health impact, while floods have produced the greatest total economic damage in the dataset.
The analysis begins with the original compressed CSV file supplied for the assignment.
data_file <- "repdata_data_StormData.csv.bz2"
storm <- read.csv(
bzfile(data_file),
stringsAsFactors = FALSE,
fileEncoding = "latin1"
)
dim(storm)
## [1] 902297 37
Only the variables required for the analysis are retained.
storm_analysis <- storm[, c(
"EVTYPE",
"FATALITIES",
"INJURIES",
"PROPDMG",
"PROPDMGEXP",
"CROPDMG",
"CROPDMGEXP"
)]
Event names are standardized by converting them to uppercase, trimming leading and trailing spaces, and replacing repeated spaces with one space. This addresses minor formatting differences while avoiding subjective recoding of historical event categories.
storm_analysis$EVTYPE <- toupper(trimws(storm_analysis$EVTYPE))
storm_analysis$EVTYPE <- gsub(
"[[:space:]]+",
" ",
storm_analysis$EVTYPE
)
Population-health impact is defined as fatalities plus injuries.
storm_analysis$HEALTH_IMPACT <-
storm_analysis$FATALITIES +
storm_analysis$INJURIES
Property and crop damage are recorded using numeric values together
with exponent codes. The function below converts the exponent codes into
multipliers. The principal codes are H for hundreds,
K for thousands, M for millions, and
B for billions. Numeric codes are treated as powers of ten.
Blank or unrecognized codes are assigned a multiplier of one.
damage_multiplier <- function(x) {
x <- toupper(trimws(as.character(x)))
multiplier <- rep(1, length(x))
multiplier[x == "H"] <- 1e2
multiplier[x == "K"] <- 1e3
multiplier[x == "M"] <- 1e6
multiplier[x == "B"] <- 1e9
numeric_codes <- grepl("^[0-9]$", x)
multiplier[numeric_codes] <-
10 ^ as.numeric(x[numeric_codes])
multiplier
}
The property and crop damage variables are converted to dollars and combined.
storm_analysis$PROPERTY_DAMAGE <-
storm_analysis$PROPDMG *
damage_multiplier(storm_analysis$PROPDMGEXP)
storm_analysis$CROP_DAMAGE <-
storm_analysis$CROPDMG *
damage_multiplier(storm_analysis$CROPDMGEXP)
storm_analysis$ECONOMIC_DAMAGE <-
storm_analysis$PROPERTY_DAMAGE +
storm_analysis$CROP_DAMAGE
The combined number of fatalities and injuries is summed for each event type.
health_summary <- aggregate(
HEALTH_IMPACT ~ EVTYPE,
data = storm_analysis,
FUN = sum,
na.rm = TRUE
)
health_summary <- health_summary[
order(health_summary$HEALTH_IMPACT, decreasing = TRUE),
]
top_health <- head(health_summary, 10)
top_health
## EVTYPE HEALTH_IMPACT
## 745 TORNADO 96979
## 107 EXCESSIVE HEAT 8428
## 766 TSTM WIND 7461
## 145 FLOOD 7259
## 407 LIGHTNING 6046
## 234 HEAT 3037
## 129 FLASH FLOOD 2755
## 376 ICE STORM 2064
## 672 THUNDERSTORM WIND 1621
## 873 WINTER STORM 1527
health_plot <- top_health[
order(top_health$HEALTH_IMPACT),
]
par(mar = c(5, 12, 4, 2))
barplot(
health_plot$HEALTH_IMPACT,
names.arg = health_plot$EVTYPE,
horiz = TRUE,
las = 1,
cex.names = 0.8,
main = "Weather Events Most Harmful to Population Health",
xlab = "Combined Fatalities and Injuries"
)
Tornadoes caused the greatest combined population-health impact, with 96,979 recorded fatalities and injuries. Excessive heat, thunderstorm wind, floods, and lightning were the next most harmful event types.
Reported property and crop damages are summed for each event type.
economic_summary <- aggregate(
ECONOMIC_DAMAGE ~ EVTYPE,
data = storm_analysis,
FUN = sum,
na.rm = TRUE
)
economic_summary <- economic_summary[
order(economic_summary$ECONOMIC_DAMAGE, decreasing = TRUE),
]
top_economic <- head(economic_summary, 10)
top_economic
## EVTYPE ECONOMIC_DAMAGE
## 145 FLOOD 150319678257
## 361 HURRICANE/TYPHOON 71913712800
## 745 TORNADO 57362333946
## 587 STORM SURGE 43323541000
## 203 HAIL 18761221986
## 129 FLASH FLOOD 18244041078
## 75 DROUGHT 15018672000
## 352 HURRICANE 14610229010
## 517 RIVER FLOOD 10148404500
## 376 ICE STORM 8967041360
economic_plot <- top_economic[
order(top_economic$ECONOMIC_DAMAGE),
]
par(mar = c(5, 12, 4, 2))
barplot(
economic_plot$ECONOMIC_DAMAGE / 1e9,
names.arg = economic_plot$EVTYPE,
horiz = TRUE,
las = 1,
cex.names = 0.8,
main = "Weather Events with the Greatest Economic Consequences",
xlab = "Combined Property and Crop Damage (Billions of Dollars)"
)
Floods caused the greatest total economic damage, at approximately $150.32 billion. Hurricane/typhoon events, tornadoes, storm surges, and hail were also among the event types with the largest economic consequences.
The NOAA Storm Database indicates that tornadoes have been the most harmful event type with respect to combined fatalities and injuries. Floods have produced the greatest combined property and crop damage. Therefore, the event types responsible for the greatest population-health effects are not identical to those responsible for the greatest economic losses.