This analysis explores the NOAA Storm Database to determine which weather event types are most harmful to population health and which cause the greatest economic damage in the United States. Population health impact is measured using fatalities and injuries, while economic consequences are calculated from property and crop damage. The analysis starts from the raw compressed CSV file and performs necessary data transformations inside this document. Results show that tornadoes are the leading cause of fatalities and injuries. Floods and hurricanes cause the largest economic damage. These findings can help government officials prioritize preparedness and resource allocation.
# Load required libraries
library(dplyr)
##
## 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)
# Read raw compressed file (must be in working directory)
storm <- read.csv("repdata_data_StormData.csv.bz2")
# Keep only relevant columns
storm <- storm %>%
select(EVTYPE, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP,
CROPDMG, CROPDMGEXP)
# Convert damage exponents to numeric multipliers
convert_exp <- function(exp) {
ifelse(exp %in% c("H", "h"), 1e2,
ifelse(exp %in% c("K", "k"), 1e3,
ifelse(exp %in% c("M", "m"), 1e6,
ifelse(exp %in% c("B", "b"), 1e9, 1))))
}
storm$PROP_MULT <- convert_exp(storm$PROPDMGEXP)
storm$CROP_MULT <- convert_exp(storm$CROPDMGEXP)
# Calculate total damages
storm$PROP_TOTAL <- storm$PROPDMG * storm$PROP_MULT
storm$CROP_TOTAL <- storm$CROPDMG * storm$CROP_MULT
storm$TOTAL_DAMAGE <- storm$PROP_TOTAL + storm$CROP_TOTAL
health <- storm %>%
group_by(EVTYPE) %>%
summarise(
Total_Fatalities = sum(FATALITIES),
Total_Injuries = sum(INJURIES)
) %>%
mutate(Total_Health = Total_Fatalities + Total_Injuries) %>%
arrange(desc(Total_Health))
top_health <- head(health, 10)
top_health
## # A tibble: 10 × 4
## EVTYPE Total_Fatalities Total_Injuries Total_Health
## <chr> <dbl> <dbl> <dbl>
## 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
ggplot(top_health, aes(x = reorder(EVTYPE, Total_Health), y = Total_Health)) +
geom_bar(stat="identity", fill="steelblue") +
coord_flip() +
labs(title="Top 10 Weather Events Most Harmful to Population Health",
x="Event Type",
y="Total Fatalities + Injuries")
Conclusion: Tornadoes cause the highest number of combined fatalities and injuries.
economic <- storm %>%
group_by(EVTYPE) %>%
summarise(Total_Damage = sum(TOTAL_DAMAGE)) %>%
arrange(desc(Total_Damage))
top_economic <- head(economic, 10)
top_economic
## # A tibble: 10 × 2
## EVTYPE Total_Damage
## <chr> <dbl>
## 1 FLOOD 150319678257
## 2 HURRICANE/TYPHOON 71913712800
## 3 TORNADO 57352114049.
## 4 STORM SURGE 43323541000
## 5 HAIL 18758222016.
## 6 FLASH FLOOD 17562129167.
## 7 DROUGHT 15018672000
## 8 HURRICANE 14610229010
## 9 RIVER FLOOD 10148404500
## 10 ICE STORM 8967041360
ggplot(top_economic,
aes(x = reorder(EVTYPE, Total_Damage), y = Total_Damage)) +
geom_bar(stat="identity", fill="darkred") +
coord_flip() +
labs(title="Top 10 Weather Events with Greatest Economic Damage",
x="Event Type",
y="Total Damage (USD)")
Conclusion: Floods and hurricanes generate the highest economic losses.