This study analyses the effect of weather conditions on population health and the economy in the US based on data gathered from 1950 until november 2011 by the National Weather Service. Additional information about the underlying data can be obtained. here and here
knitr::opts_chunk$set(echo = TRUE)
# Don't use scientific notation
options(scipen = 999)
# Load required packages
library(dplyr)
library(ggplot2)
library(reshape2)
The analysis required the R packages dplyr, ggplot2 and reshape2.
zipfile_url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
zipfile_path <- "data/noaa_storm_data.csv.bz2"
Data for this analysis was downloaded as a bz2 zipped file from the web. The compressed raw csv file with headers was read into an R dataframe. Empty strings were interpreted as NA values.
# Download bz2 zipped file to data directory and read it
if (!dir.exists("data")) {
dir.create("data")
}
if (!file.exists(zipfile_path)) {
download.file(zipfile_url, zipfile_path)
}
if (!exists("storm_df")) {
storm_df <- read.csv(zipfile_path, header=TRUE, na.strings = "")
}
Data was grouped by weather event (EVTYPE) in order to analyse the health and economic effects of these events.
storm_data_by_event <- storm_df %>% group_by(EVTYPE)
The impact on population health by weather event type was estimated using the sum of all reported fatality (FATALITIES) and injury (INJURIES) numbers for these events. A plot was created which reports these totals for the most lethal (i.e. highest fatality totals) weather events.
# Rank total fatalities by event type
fatalities_by_event <- storm_data_by_event %>%
summarize(total_fatalities=sum(FATALITIES)) %>%
# Rank events by total fatalities
arrange(desc(total_fatalities)) %>%
as.data.frame
# Top 20 total fatalities during recorded period by weather event
head(fatalities_by_event, 20)
## EVTYPE total_fatalities
## 1 TORNADO 5633
## 2 EXCESSIVE HEAT 1903
## 3 FLASH FLOOD 978
## 4 HEAT 937
## 5 LIGHTNING 816
## 6 TSTM WIND 504
## 7 FLOOD 470
## 8 RIP CURRENT 368
## 9 HIGH WIND 248
## 10 AVALANCHE 224
## 11 WINTER STORM 206
## 12 RIP CURRENTS 204
## 13 HEAT WAVE 172
## 14 EXTREME COLD 160
## 15 THUNDERSTORM WIND 133
## 16 HEAVY SNOW 127
## 17 EXTREME COLD/WIND CHILL 125
## 18 STRONG WIND 103
## 19 BLIZZARD 101
## 20 HIGH SURF 101
# Rank total injuries by event type
injuries_by_event <- storm_data_by_event %>%
summarize(total_injuries=sum(INJURIES)) %>%
# Rank events by total injuries
arrange(desc(total_injuries)) %>%
as.data.frame
# Top 20 total injuries during recorded period by weather event:
head(injuries_by_event, 20)
## EVTYPE total_injuries
## 1 TORNADO 91346
## 2 TSTM WIND 6957
## 3 FLOOD 6789
## 4 EXCESSIVE HEAT 6525
## 5 LIGHTNING 5230
## 6 HEAT 2100
## 7 ICE STORM 1975
## 8 FLASH FLOOD 1777
## 9 THUNDERSTORM WIND 1488
## 10 HAIL 1361
## 11 WINTER STORM 1321
## 12 HURRICANE/TYPHOON 1275
## 13 HIGH WIND 1137
## 14 HEAVY SNOW 1021
## 15 WILDFIRE 911
## 16 THUNDERSTORM WINDS 908
## 17 BLIZZARD 805
## 18 FOG 734
## 19 WILD/FOREST FIRE 545
## 20 DUST STORM 440
# Merge fatality and injury data, primarily sort by fatalities
population_hazards_by_event <- merge(fatalities_by_event, injuries_by_event, by="EVTYPE") %>%
arrange(desc(total_fatalities), desc(total_injuries))
# Create barplot displaying health effects of 15 most lethal weather events
population_hazards_by_event_head_melt <- melt(population_hazards_by_event[1:15,], id="EVTYPE")
most_fatal_events_ranked <- unique(population_hazards_by_event_head_melt$EVTYPE)
most_lethal_weather_events_plot <- ggplot(population_hazards_by_event_head_melt,
aes(x=factor(EVTYPE, levels=most_fatal_events_ranked), y=value, fill=variable)) +
geom_bar(stat="identity", position="dodge") +
labs(title="Most lethal weather events in US (1950 - 2011)", x="Weather event", y="Population") +
scale_fill_discrete(name="Health effect",
breaks=c("total_fatalities", "total_injuries"),
labels=c("Total fatalities", "Total injuries")) +
scale_y_log10() +
theme(axis.text.x = element_text(angle = 65, hjust = 1))
The economic damages by weather event type were estimated using the sum of all reported property damages (PROPDMG) and damages to crops (CROPDMG).
# Rank total property damages by weather event type
property_damage_by_event <- storm_data_by_event %>%
summarize(total_property_damage = sum(PROPDMG)) %>%
arrange(desc(total_property_damage)) %>%
as.data.frame
# Ranking of weather events with highest total property damages ($) during recorded period
head(property_damage_by_event, 20)
## EVTYPE total_property_damage
## 1 TORNADO 3212258.16
## 2 FLASH FLOOD 1420124.59
## 3 TSTM WIND 1335965.61
## 4 FLOOD 899938.48
## 5 THUNDERSTORM WIND 876844.17
## 6 HAIL 688693.38
## 7 LIGHTNING 603351.78
## 8 THUNDERSTORM WINDS 446293.18
## 9 HIGH WIND 324731.56
## 10 WINTER STORM 132720.59
## 11 HEAVY SNOW 122251.99
## 12 WILDFIRE 84459.34
## 13 ICE STORM 66000.67
## 14 STRONG WIND 62993.81
## 15 HIGH WINDS 55625.00
## 16 HEAVY RAIN 50842.14
## 17 TROPICAL STORM 48423.68
## 18 WILD/FOREST FIRE 39344.95
## 19 FLASH FLOODING 28497.15
## 20 URBAN/SML STREAM FLD 26051.94
# Rank total crop damages by weather event type
crop_damage_by_event <- storm_data_by_event %>%
summarize(total_crop_damage = sum(CROPDMG)) %>%
arrange(desc(total_crop_damage)) %>%
as.data.frame
# Ranking of weather events with highest total crop damages ($) during recorded period:
head(crop_damage_by_event, 20)
## EVTYPE total_crop_damage
## 1 HAIL 579596.28
## 2 FLASH FLOOD 179200.46
## 3 FLOOD 168037.88
## 4 TSTM WIND 109202.60
## 5 TORNADO 100018.52
## 6 THUNDERSTORM WIND 66791.45
## 7 DROUGHT 33898.62
## 8 THUNDERSTORM WINDS 18684.93
## 9 HIGH WIND 17283.21
## 10 HEAVY RAIN 11122.80
## 11 FROST/FREEZE 7034.14
## 12 EXTREME COLD 6121.14
## 13 TROPICAL STORM 5899.12
## 14 HURRICANE 5339.31
## 15 FLASH FLOODING 5126.05
## 16 HURRICANE/TYPHOON 4798.48
## 17 WILDFIRE 4364.20
## 18 TSTM WIND/HAIL 4356.65
## 19 WILD/FOREST FIRE 4189.54
## 20 LIGHTNING 3580.61
# Merge total property and crop damages and calculate total economic damages by weather event
economic_damage_by_event <- merge(property_damage_by_event, crop_damage_by_event, by="EVTYPE") %>%
mutate(total_economic_damage = total_property_damage + total_crop_damage) %>%
arrange(desc(total_economic_damage)) %>%
as.data.frame
# Weather events with highest total economic damages ($) (property and crop damage)
head(economic_damage_by_event[, c("EVTYPE", "total_economic_damage")], 20)
## EVTYPE total_economic_damage
## 1 TORNADO 3312276.68
## 2 FLASH FLOOD 1599325.05
## 3 TSTM WIND 1445168.21
## 4 HAIL 1268289.66
## 5 FLOOD 1067976.36
## 6 THUNDERSTORM WIND 943635.62
## 7 LIGHTNING 606932.39
## 8 THUNDERSTORM WINDS 464978.11
## 9 HIGH WIND 342014.77
## 10 WINTER STORM 134699.58
## 11 HEAVY SNOW 124417.71
## 12 WILDFIRE 88823.54
## 13 ICE STORM 67689.62
## 14 STRONG WIND 64610.71
## 15 HEAVY RAIN 61964.94
## 16 HIGH WINDS 57384.60
## 17 TROPICAL STORM 54322.80
## 18 WILD/FOREST FIRE 43534.49
## 19 DROUGHT 37997.67
## 20 FLASH FLOODING 33623.20
# Create barplot displaying total economic damage of weather events with highest economic impact
highest_economic_damages_by_weather_events_plot <- ggplot(economic_damage_by_event[1:15,],
aes(x=factor(EVTYPE, levels=economic_damage_by_event[1:15,]$EVTYPE), y=total_economic_damage/(10^6))) +
geom_bar(stat="identity") +
labs(title="Weather events with most economic damages in US (1950 - 2011)", x="Weather event", y="Damages ($M)") +
theme(axis.text.x = element_text(angle = 65, hjust = 1))
# Create barplot displaying total economic damage of weather events with highest economic impact as fraction of overall weather related damages
total_economic_damage_overall <- sum(economic_damage_by_event$total_economic_damage)
highest_economic_damages_fraction_by_weather_events_plot <- ggplot(economic_damage_by_event[1:30,],
aes(x=factor(EVTYPE, levels=economic_damage_by_event[1:30,]$EVTYPE), y=(total_economic_damage/total_economic_damage_overall)*100)) +
geom_bar(stat="identity") +
labs(title="Weather events with most economic damages in US (1950 - 2011)", x="Weather event", y="Damages (%)") +
theme(axis.text.x = element_text(angle = 65, hjust = 1))
most_lethal_weather_events_plot
Tornadoes seem to have been by far the most harmful for the health of the US population from 1950 until november 2011.
highest_economic_damages_by_weather_events_plot
highest_economic_damages_fraction_by_weather_events_plot
More then a quarter of all weather related economic damages in the US from 1950 until november 2011 are attributable to tornadoes.
head(crop_damage_by_event, 3)
## EVTYPE total_crop_damage
## 1 HAIL 579596.3
## 2 FLASH FLOOD 179200.5
## 3 FLOOD 168037.9
Hail is the biggest contributor to crop related economic damages