This project is for the Coursera class, “Reproducible Research” by Johns Hopkins University. In this project, we analyze data from the National Weather Service’s Storm Data Documentation. We were tasked to determine which types of national disasters were the most damaging to population health and property. In both cases, we found that Tornadoes were historically the most damaging coming up at 3,270 fatalities, 35,581 injuries, and $48.46 Billion. Flood and heat related incidents were also among the most damaging to population health. However, when it came to property damage, heat related incidents were nowhere to be found. Flooding, hailing, hurricanes, and ice storms were now among the most damaging. Below, you can find the data and code used to find our conclusions.
The raw data for this project was taken from the National Weather Service’s Storm Data Documentation and was provided by the course website on Coursera through the following link.
https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2
Tidyverse was used in this project.
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.3
## Warning: package 'ggplot2' was built under R version 4.3.3
## Warning: package 'tibble' was built under R version 4.3.3
## Warning: package 'dplyr' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.0 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
This data was loaded into RStudio through the following code.
RawData <- read.csv("repdata_data_StormData.csv")
head(RawData)
## 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
This data contained more than necessary so only the columns necessary for our analysis were separated out from the RawData.
NecessaryData <- select(RawData, EVTYPE, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP)
head(NecessaryData)
## EVTYPE FATALITIES INJURIES PROPDMG PROPDMGEXP
## 1 TORNADO 0 15 25.0 K
## 2 TORNADO 0 0 2.5 K
## 3 TORNADO 0 2 25.0 K
## 4 TORNADO 0 2 2.5 K
## 5 TORNADO 0 2 2.5 K
## 6 TORNADO 0 6 2.5 K
The data was then separated out to find the sum of Fatalities, Injuries, and Property damages per Natural Disaster type. First, as there was no established convention for naming the EVTYPE variable, I used subset to only select entries that were higher than a certain number. I chose 5 fatalities, 100 injuries, and property damage denoted by the Millions PROPDMGEXP when analyzing each variable.
HighFatality <- subset(NecessaryData, NecessaryData$FATALITIES > 5)
HighInjury <- subset(NecessaryData, NecessaryData$INJURIES > 100)
PropertyDamage <- subset(NecessaryData, NecessaryData$PROPDMG > 0)
##take only the property damage in the scale of millions
HighPropertyDamage <- subset(PropertyDamage, PropertyDamage$PROPDMGEXP == "M")
These numbers were then summed up and ordered from highest to lowest using the aggregate function to find the total fatalities, injuries, and property damage per natural disaster.
HighFatalitySum <- aggregate(HighFatality["FATALITIES"], HighFatality["EVTYPE"], sum)
##order from highest to lowest fatality sum
HighFatalitySum <- HighFatalitySum[order(HighFatalitySum$FATALITIES, decreasing = TRUE),]
HighInjurySum <- aggregate(HighInjury["INJURIES"], HighInjury["EVTYPE"], sum)
##order from highest to lowest injury sum
HighInjurySum <- HighInjurySum[order(HighInjurySum$INJURIES, decreasing = TRUE),]
HighPropertyDamageSum <- aggregate(HighPropertyDamage["PROPDMG"], HighPropertyDamage["EVTYPE"], sum)
##order from highest to lowest property damage sum
HighPropertyDamageSum <- HighPropertyDamageSum[order(HighPropertyDamageSum$PROPDMG, decreasing = TRUE),]
Finally, the top 10 natural disasters for each type were isolated in their own data frames for plotting.
TopTenFatality <- HighFatalitySum[1:10,]
TopTenInjury <- HighInjurySum[1:10,]
TopTenPropDam <- HighPropertyDamageSum[1:10,]
The following ggplot2 code was used to generate a bar graph of the top 10 most fatal types of natural disasters. The most fatal type of natural disaster was by and far tornadoes followed by heat related incidents and flood related incidents. Hurricanes, wildfires, and tsunamis also made it into the top 10 but had much smaller numbers of fatalities.
##graph fatality statistics
Fatality <- ggplot(data = TopTenFatality,
mapping = aes(x = reorder(EVTYPE, -FATALITIES), FATALITIES, fill = reorder(EVTYPE,-FATALITIES)))
Fatality + geom_bar(stat = "identity") +
theme(axis.text.x = element_blank()) +
xlab("Disaster Type") +
ylab("Number of Fatalities") +
guides(fill = guide_legend(title = "Disaster Type")) +
ggtitle("Top 10 Fatal Natural Disaster Types")
##print numbers
print(TopTenFatality)
## EVTYPE FATALITIES
## 30 TORNADO 3270
## 5 EXCESSIVE HEAT 1089
## 13 HEAT 707
## 14 HEAT WAVE 137
## 9 FLASH FLOOD 118
## 8 EXTREME HEAT 83
## 11 FLOOD 56
## 20 HURRICANE/TYPHOON 41
## 38 WILDFIRE 34
## 35 TSUNAMI 32
The following ggplot2 code was used to generate a bar graph of the top 10 natural disaster types that caused the most injuries. At the top was yet again tornadoes at the highest position followed by flooding and heat related incidents. Unlike fatalities, blizzards and ice storms made it into the top 10 injury causing natural disasters. Hurricanes and tropical storms also caused a large number of injuries.
##graph injury statistics
Injury <- ggplot(data = TopTenInjury,
mapping = aes(x = reorder(EVTYPE, - INJURIES),INJURIES, fill = reorder(EVTYPE,-INJURIES)))
Injury + geom_bar(stat = "identity") +
theme(axis.text.x = element_blank()) +
xlab("Disaster Type") +
ylab("Number of Injuries") +
guides(fill = guide_legend(title = "DisasterType")) +
ggtitle("Top 10 Injury Causing Natural Disaster Types")
##print numbers
print(TopTenInjury)
## EVTYPE INJURIES
## 12 TORNADO 35581
## 5 FLOOD 5125
## 2 EXCESSIVE HEAT 3721
## 11 ICE STORM 1568
## 7 HEAT 1363
## 10 HURRICANE/TYPHOON 1200
## 1 BLIZZARD 535
## 4 FLASH FLOOD 402
## 8 HEAT WAVE 200
## 13 TROPICAL STORM 200
The following ggplot 2 code was used to generate a bar graph ot the top 10 most damaging natural disaster types. Tornadoes are yet again at the top. The gap between the top is not quite as high as in fatalities and injuries with flood related incidents pretty close to tornadoes. We also see some new entries such as hail, ice storms, and wind.
##graph property damage statistics
PropDam <- ggplot(data = TopTenPropDam,
mapping = aes(x = reorder(EVTYPE, -PROPDMG),PROPDMG, fill = reorder(EVTYPE,-PROPDMG)))
PropDam + geom_bar(stat = "identity") +
theme(axis.text.x = element_blank()) +
xlab("Disaster Type") +
ylab("Property Damage in USD (Millions)") +
guides(fill = guide_legend(title = "Disaster Type")) +
ggtitle("Top 10 Most Damaging Natural Disaster Types")
##print numbers
print(TopTenPropDam)
## EVTYPE PROPDMG
## 106 TORNADO 48462.18
## 26 FLOOD 21279.18
## 22 FLASH FLOOD 13734.98
## 41 HAIL 13252.26
## 68 HURRICANE 6158.97
## 76 ICE STORM 3882.86
## 72 HURRICANE/TYPHOON 3803.87
## 62 HIGH WIND 3649.00
## 123 WILDFIRE 3644.30
## 113 TSTM WIND 3152.17