This publication investigates the top 15 contributors.
Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern.
We’re going to explore the NOAA Storm Database and answer some basic questions about severe weather events:
The data for this assignment come in the form of a comma-separated-value file compressed via the bzip2 algorithm to reduce its size. It can be downloaded from the following web site:
Documentation of the database if available by the links below. The links contain information about how some of the variables are constructed/defined.
The events in the database start in the year 1950 and end in November 2011. In the earlier years of the database there are generally fewer events recorded, most likely due to a lack of good records. More recent years should be considered more complete.
The following code will download, decompress the file and read the data only if it does not exist.
# If the file does not exist, download it from URL
if (!file.exists("./data/NOAA_storm_data.csv")) {
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2",
"./data/NOAA_storm_data.csv.bz2")
}
# Decompress the file using bunzip2
if(!file.exists("./data/NOAA_storm_data.csv")) {
library(R.utils)
bunzip2("./data/NOAA_storm_data.csv.bz2",
"./data/NOAA_storm_data.csv",
remove = FALSE,overwrite=TRUE)
}
StormData <- read.csv("./data/NOAA_storm_data.csv")
head(StormData)
## STATE__ BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1 1 4/18/1950 0:00:00 0130 CST 97 MOBILE AL
## 2 1 4/18/1950 0:00:00 0145 CST 3 BALDWIN AL
## 3 1 2/20/1951 0:00:00 1600 CST 57 FAYETTE AL
## 4 1 6/8/1951 0:00:00 0900 CST 89 MADISON AL
## 5 1 11/15/1951 0:00:00 1500 CST 43 CULLMAN AL
## 6 1 11/15/1951 0:00:00 2000 CST 77 LAUDERDALE AL
## EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END
## 1 TORNADO 0 0
## 2 TORNADO 0 0
## 3 TORNADO 0 0
## 4 TORNADO 0 0
## 5 TORNADO 0 0
## 6 TORNADO 0 0
## COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1 NA 0 14.0 100 3 0 0
## 2 NA 0 2.0 150 2 0 0
## 3 NA 0 0.1 123 2 0 0
## 4 NA 0 0.0 100 2 0 0
## 5 NA 0 0.0 150 2 0 0
## 6 NA 0 1.5 177 2 0 0
## INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1 15 25.0 K 0
## 2 0 2.5 K 0
## 3 2 25.0 K 0
## 4 2 2.5 K 0
## 5 2 2.5 K 0
## 6 6 2.5 K 0
## LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1 3040 8812 3051 8806 1
## 2 3042 8755 0 0 2
## 3 3340 8742 0 0 3
## 4 3458 8626 0 0 4
## 5 3412 8642 0 0 5
## 6 3450 8748 0 0 6
Load the tidyverse and ggplot2 libraries to replicate the data analysis and visualization.
library(tidyverse)
## ── Attaching packages ─────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 2.2.1 ✔ purrr 0.2.4
## ✔ tibble 1.3.4 ✔ dplyr 0.7.4
## ✔ tidyr 0.7.2 ✔ stringr 1.2.0
## ✔ readr 1.1.1 ✔ forcats 0.2.0
## ── Conflicts ────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(ggplot2)
Data related to public health and economics, requires looking at propery damage, fatalities and injuries in aggregate. This answers the question: ‘what events caused the most health or economic impacts’. For brevity we will look at the top 15 events for each impacted category. The data tends to be steep, supporting 15 as representative for the entire set.
Storm weather has contributed to 15,145 fatalities, 140,528 injuries and $10,884,500 in property damages in the US.
# Subset
storm_data <- select(StormData, EVTYPE, FATALITIES, INJURIES, PROPDMG)
# Rename cols
names(storm_data) <- c("event","fatalities","injuries","property_damage")
sum(storm_data$fatalities)
## [1] 15145
sum(storm_data$injuries)
## [1] 140528
sum(storm_data$property_damage)
## [1] 10884500
Aggregate fatality, injury and property damage data group the data by event type. The results are calculated by the sum of the events and only the top 15 are included in the analysis.
af <- aggregate(fatalities ~ event, data = storm_data, FUN = sum)
ai <- aggregate(injuries ~ event, data = storm_data, FUN = sum)
ap <- aggregate(property_damage ~ event, data = storm_data, FUN = sum)
top_f <- af[order(-af$fatalities), ][1:15, ]
top_i <- ai[order(-ai$injuries), ][1:15, ]
top_p <- ap[order(-ap$property_damage), ][1:15, ]
Tornadoes are responsible for the most fatalities.
fatalities_plot <- ggplot(data = top_f, aes(x = reorder(event, fatalities), y = fatalities)) +
geom_bar( stat = "identity", aes(fill = -fatalities)) +
ylab("Fatalities") +
xlab("Events") +
theme_minimal() +
theme(legend.position='none') +
coord_flip()
fatalities_plot +
ggtitle("Number of Fatalities by Event")
Tornadoes are also responsible for the most fatalities.
injuries_plot <- ggplot(data = top_i, aes(x = reorder(event, injuries), y = injuries)) +
geom_bar( stat = "identity", aes(fill = -injuries)) +
ylab("Injuries") +
xlab("Events") +
theme_minimal() +
theme(legend.position='none') +
coord_flip()
injuries_plot +
ggtitle("Number of Injuries by Event")
property_damage_plot <- ggplot(data = top_p, aes(x = reorder(event, property_damage), y = property_damage)) +
geom_bar( stat = "identity", aes(fill = -property_damage)) +
ylab("Cost of Property Damages") +
xlab("Events") +
theme_minimal() +
theme(legend.position='none') +
coord_flip()
property_damage_plot +
ggtitle("Cost of Property Damage by Event ($)")
Tornadoes account for the highest number of fatalities, injuries and property damages of all storm events.