This analysis examines the NOAA Storm Database to determine which weather events have the greatest impact on population health and economic damage. Tornadoes cause the most fatalities and injuries, while floods cause the highest economic losses.
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)
data <- read.csv("stormdata.csv.bz2")
dim(data)
## [1] 902297 37
head(data)
## STATE__ BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE EVTYPE
## 1 1 4/18/1950 0:00:00 0130 CST 97 MOBILE AL TORNADO
## 2 1 4/18/1950 0:00:00 0145 CST 3 BALDWIN AL TORNADO
## 3 1 2/20/1951 0:00:00 1600 CST 57 FAYETTE AL TORNADO
## 4 1 6/8/1951 0:00:00 0900 CST 89 MADISON AL TORNADO
## 5 1 11/15/1951 0:00:00 1500 CST 43 CULLMAN AL TORNADO
## 6 1 11/15/1951 0:00:00 2000 CST 77 LAUDERDALE AL TORNADO
## BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END COUNTYENDN
## 1 0 0 NA
## 2 0 0 NA
## 3 0 0 NA
## 4 0 0 NA
## 5 0 0 NA
## 6 0 0 NA
## END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES INJURIES PROPDMG
## 1 0 14.0 100 3 0 0 15 25.0
## 2 0 2.0 150 2 0 0 0 2.5
## 3 0 0.1 123 2 0 0 2 25.0
## 4 0 0.0 100 2 0 0 2 2.5
## 5 0 0.0 150 2 0 0 2 2.5
## 6 0 1.5 177 2 0 0 6 2.5
## PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES LATITUDE LONGITUDE
## 1 K 0 3040 8812
## 2 K 0 3042 8755
## 3 K 0 3340 8742
## 4 K 0 3458 8626
## 5 K 0 3412 8642
## 6 K 0 3450 8748
## LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1 3051 8806 1
## 2 0 0 2
## 3 0 0 3
## 4 0 0 4
## 5 0 0 5
## 6 0 0 6
health_data <- data %>%
group_by(EVTYPE) %>%
summarise(
fatalities = sum(FATALITIES, na.rm = TRUE),
injuries = sum(INJURIES, na.rm = TRUE)
)
top_health <- health_data %>%
mutate(total = fatalities + injuries) %>%
arrange(desc(total)) %>%
head(10)
library(ggplot2)
ggplot(top_health, aes(x = reorder(EVTYPE, total), y = total)) +
geom_bar(stat = "identity") +
coord_flip() +
labs(title = "Top 10 Events Harmful to Population Health",
x = "Event Type",
y = "Total Fatalities and Injuries")
Tornadoes are the most harmful events to population health, followed by excessive heat and floods.
convert_exp <- function(exp) {
ifelse(exp == "K", 1e3,
ifelse(exp == "M", 1e6,
ifelse(exp == "B", 1e9, 1)))
}
data$PROPDMGEXP <- convert_exp(data$PROPDMGEXP)
data$CROPDMGEXP <- convert_exp(data$CROPDMGEXP)
data$PROPDMG_TOTAL <- data$PROPDMG * data$PROPDMGEXP
data$CROPDMG_TOTAL <- data$CROPDMG * data$CROPDMGEXP
econ_data <- data %>%
group_by(EVTYPE) %>%
summarise(
property = sum(PROPDMG_TOTAL, na.rm = TRUE),
crop = sum(CROPDMG_TOTAL, na.rm = TRUE)
)
top_econ <- econ_data %>%
mutate(total = property + crop) %>%
arrange(desc(total)) %>%
head(10)
ggplot(top_econ, aes(x = reorder(EVTYPE, total), y = total)) +
geom_bar(stat = "identity") +
coord_flip() +
labs(title = "Top 10 Events with Greatest Economic Damage",
x = "Event Type",
y = "Damage (USD)")
Floods and hurricanes cause the greatest economic damage.