Storms and other severe weather events can cause both public health and economic problems. In this study we examined first which type of event is causing the most fatalities and injuries (population health damage) and second which type of event causes the most economic damages, separated by property and crop damages.
Results showed that tornadoes caused the most damage in terms of fatalities, injuries and property damage, while hail caused the most crop damage.
The data is downloaded from the web, unzipped and loaded to a dataframe called stormData:
library(readr)
library(utils)
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)
library(stats)
library(forcats)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
bz2File<-"repdata-data-StormData.csv.bz2"
if (!file.exists(bz2File)){
url<-"https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(url, bz2File, mode="wb")
}
stormData<-read.csv(bz2File, header = TRUE, sep=",")
In all cases, the data was grouped by event type and then sum of the variable analyzed(fatalities, injuries, property damage or crop damage) was taken using the summarize function. The list was arranged in descending order to have the highest values on top. The 10 top rows were taken to visualize in the plots. The plots were grouped in a single figure for population health and a single figure for economic damages for easy comparison.
#1. Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?
fatalities_per_event <- stormData %>%
group_by(EVTYPE)%>%
summarize(total=sum(FATALITIES,na.rm = TRUE)) %>%
arrange(desc(total))
max_fatalities <- fatalities_per_event[1:10,]
fatplot <- ggplot(max_fatalities, aes(x=EVTYPE,y=total))+
geom_bar(stat = "identity")+
scale_x_discrete(guide = guide_axis(angle = 30))+
aes(x = fct_inorder(EVTYPE))+
labs(x= "Event type", y="Fatalities",
title = "Top 10 Events With Most Fatalitites")
injuries_per_event <- stormData %>%
group_by(EVTYPE)%>%
summarize(total=sum(INJURIES,na.rm = TRUE)) %>%
arrange(desc(total))
max_injuries <- injuries_per_event[1:10,]
injplot <- ggplot(max_injuries, aes(x=EVTYPE,y=total))+
geom_bar(stat = "identity")+
scale_x_discrete(guide = guide_axis(angle = 30))+
aes(x = fct_inorder(EVTYPE))+
labs(x= "Event type", y="Injuries",
title = "Top 10 Events With Most Injuries",
caption = "From left to right the highest to 10th highest fatalities/injuries")
grid.arrange(fatplot,injplot)
For both fatalities and injuries the event with more harm was tornadoes.
#2. Across the United States, which types of events have the greatest economic consequences?
We will use property (PROPDMG, num) and crop (CROPDMG, num) damages to answer this question.
The same type of analysis from question 1 was performed for question 2 but changing the variable (column) analyzed.
propdmg_per_event <- stormData %>%
group_by(EVTYPE)%>%
summarize(total=sum(PROPDMG,na.rm = TRUE)) %>%
arrange(desc(total))
max_propdmg <- propdmg_per_event[1:10,]
propplot <- ggplot(max_propdmg, aes(x=EVTYPE,y=total))+
geom_bar(stat = "identity")+
scale_x_discrete(guide = guide_axis(angle = 30))+
aes(x = fct_inorder(EVTYPE))+
labs(x= "Event type", y="Property damage",
title = "Top 10 Events Causing the Most Property Damage")
cropdmg_per_event <- stormData %>%
group_by(EVTYPE)%>%
summarize(total=sum(CROPDMG,na.rm = TRUE)) %>%
arrange(desc(total))
max_cropdmg <- cropdmg_per_event[1:10,]
cropplot <- ggplot(max_cropdmg, aes(x=EVTYPE,y=total))+
geom_bar(stat = "identity")+
scale_x_discrete(guide = guide_axis(angle = 30))+
aes(x = fct_inorder(EVTYPE))+
labs(x= "Event type", y="Crop damage",
title = "Top 10 Events Causing the Most Crop Damage",
caption = "From left to right the highest to 10th highest economic damage")
grid.arrange(propplot,cropplot)
Tornadoes are the event most harmful to population health. In the case of fatalities, excessive heat, flash flood and heat were the following ones. In the case of injuries, they were TSTM wind (Thunderstom wind), flood and excessive heat.
In terms of economic consequences, tornadoes are the event causing the most property damage, followed by flash flood, TSTM wind and flood. Hail is the event causing the most crop damage followed by flash flood, flood and TSTM wind.
Overall tornadoes seems to be the single event affecting the most the health and economic damages in the USA.