This analysis explores the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database to determine which severe weather events are most harmful to population health and the economy. The data spans from 1950 to 2011. To evaluate health impacts, fatalities and injuries were aggregated by event type. To evaluate economic consequences, property and crop damage estimates were converted into total dollar amounts and aggregated. The analysis concludes that Tornadoes are overwhelmingly the most harmful to population health, causing the highest number of injuries and fatalities. Meanwhile, Floods have the greatest economic consequences, causing the highest total property and crop damage.
First, we load the required libraries and read the raw bzip2
compressed dataset. Because this dataset is large, we use
cache = TRUE so it only has to load once.
library(dplyr)
library(ggplot2)
# Read the raw data
storm_data <- read.csv("repdata_data_StormData.csv.bz2")
Next, we process the data. For health impacts, we simply add
Fatalities and Injuries. For economic impacts, the damage amounts are
split into a base number (PROPDMG, CROPDMG)
and an alphabetical exponent (PROPDMGEXP,
CROPDMGEXP) like ‘K’ for thousands, ‘M’ for millions, and
‘B’ for billions. We must convert these letters into numerical
multipliers.
# Select only the columns we need to save memory
clean_data <- storm_data %>%
select(EVTYPE, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP, CROPDMG, CROPDMGEXP)
# Create a function to map the exponents to multipliers
clean_data <- clean_data %>%
mutate(
PROPMULT = case_when(
toupper(PROPDMGEXP) == "B" ~ 10^9,
toupper(PROPDMGEXP) == "M" ~ 10^6,
toupper(PROPDMGEXP) == "K" ~ 10^3,
toupper(PROPDMGEXP) == "H" ~ 10^2,
TRUE ~ 1
),
CROPMULT = case_when(
toupper(CROPDMGEXP) == "B" ~ 10^9,
toupper(CROPDMGEXP) == "M" ~ 10^6,
toupper(CROPDMGEXP) == "K" ~ 10^3,
toupper(CROPDMGEXP) == "H" ~ 10^2,
TRUE ~ 1
),
# Calculate Total Health and Total Economic Damage
TOTAL_HEALTH = FATALITIES + INJURIES,
TOTAL_DAMAGE = (PROPDMG * PROPMULT) + (CROPDMG * CROPMULT)
)
We aggregate the total health impact (fatalities + injuries) by event type and select the top 10 worst events.
health_data <- clean_data %>%
group_by(EVTYPE) %>%
summarize(Total_Harm = sum(TOTAL_HEALTH, na.rm = TRUE)) %>%
arrange(desc(Total_Harm)) %>%
head(10)
# Plotting the top 10 health events
ggplot(health_data, aes(x = reorder(EVTYPE, Total_Harm), y = Total_Harm)) +
geom_col(fill = "firebrick") +
coord_flip() +
labs(title = "Top 10 Most Harmful Weather Events to Population Health",
x = "Event Type",
y = "Total Fatalities & Injuries") +
theme_minimal()
As seen in the chart above, Tornadoes cause significantly more harm to population health than any other weather event.
We aggregate the total calculated dollar amount (property + crop damage) by event type and select the top 10 worst events.
econ_data <- clean_data %>%
group_by(EVTYPE) %>%
summarize(Total_Econ_Damage = sum(TOTAL_DAMAGE, na.rm = TRUE)) %>%
arrange(desc(Total_Econ_Damage)) %>%
head(10)
# Plotting the top 10 economic events
ggplot(econ_data, aes(x = reorder(EVTYPE, Total_Econ_Damage), y = Total_Econ_Damage)) +
geom_col(fill = "steelblue") +
coord_flip() +
labs(title = "Top 10 Weather Events with Greatest Economic Consequences",
x = "Event Type",
y = "Total Damage (in US Dollars)") +
theme_minimal()
As seen in the chart above, Floods cause the highest amount of economic damage, followed by Hurricanes/Typhoons and Tornadoes.