Storms and severe weather events have been implicated to cause significant public health and economic problems for communities and municipalities. The purpose of this analysis was to explore the National Oceanic and Atmospheric Administration’s (NOAA) storm database to inform future preparation and prioritization of resources for different type of such events. The events of the database start in the year 1950 and end in November 2011. We conducted an analysis using R Studio to explore which types of events are most harmful with respect to population health and which types of events have the greatest economic consequences. Our analysis indicates that tornadoes are associated with the highest numbers of fatalities and injuries, followed by excessive heat. We illustrated these findings by creating a figure containing 2 plots, one for fatalities and one for injuries. We then explored the association between weather event type and total economic deficit and our analysis indicates that floods are associated with the most significant economic deficit, followed by hurricanes and tornadoes. We illustrated these findings by creating a bar plot of the total economic damage by event type.
To begin with our analysis, we downloaded and loaded the dataset from the NOOA’s website using R and saved it to the variable “data”. We then cleaned the data using the package “dplyr” by selecting only the variables of interest, which are the type of weather event, fatalities, injuries, property and crop damage. Since the data frame contained many variations, we converted everything to uppercase and stripped out the leading/trailing white spaces. We also created two new variables called total_property_damage and total_crop_damage, which are a combination of the base numbers and their alphabetical multipliers. We then created a third variable called total_economic_damage which is the sum of the total_property_damage and total_crop_damage.
This was made possible with the following code:
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2",
destfile = "StormData.csv.bz2",
method = "curl")
data <- read.csv("StormData.csv.bz2")
##Data cleaning
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
data_clean <- data %>%
select(EVTYPE, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP, CROPDMG, CROPDMGEXP)
data_clean <- data_clean %>%
mutate(EVTYPE = toupper(trimws(EVTYPE)),
PROPDMGEXP = toupper(PROPDMGEXP),
CROPDMGEXP = toupper(CROPDMGEXP),
prop_mult = case_when(
PROPDMGEXP == "K" ~1000,
PROPDMGEXP == "M" ~ 1000000,
PROPDMGEXP == "B" ~ 1000000000,
TRUE ~ 1
),
crop_mult = case_when(
CROPDMGEXP == "K" ~1000,
CROPDMGEXP == "M" ~ 1000000,
CROPDMGEXP == "B" ~ 1000000000,
TRUE ~ 1
),
Total_Property_Damage = PROPDMG * prop_mult,
Total_Crop_Damage = CROPDMG * crop_mult
)
data_clean <- data_clean %>%
mutate(Total_Economic_Damage = Total_Property_Damage + Total_Crop_Damage)
##We noticed that there are some duplicate entries that interfere with our final results, so we also made the following merges:
data_clean$EVTYPE[grepl("HEAT", data_clean$EVTYPE)] <- "EXCESSIVE HEAT"
data_clean$EVTYPE[grepl("TSTM|THUNDERSTORM", data_clean$EVTYPE)] <- "THUNDERSTORM WIND"
data_clean$EVTYPE[grepl("HURRICANE|TYPHOON", data_clean$EVTYPE)] <- "HURRICANE"
data_clean$EVTYPE[grepl("STORM SURGE", data_clean$EVTYPE)] <- "STORM SURGE"
data_clean$EVTYPE[grepl("FLOOD|FLASH", data_clean$EVTYPE)] <- "FLOOD"
We began our analysis by exploring any potential associaton between the different types of events and increased fatality and injury counts. To this end we gathered the total of fatalities and injuries for each weather event type. We then sorted the list in a descending order and created two plots that illustrate the top 10 weather types that are associated with the highest number of fatalities and injuries respectively. Our analysis indicates that the events associated with the highest numbers of fatalities are associated with Tornadoes (number of fatalities=5,633), followed by excessive heat (number of fatalities=3,138) and flash flood (number of fatalities = 978). In regards to Injuries, Tornadoes again demonstrate a markedly high number of injuries (91,346) compared to the rest of the weather events. Thunderstorm winds follow with a total number of 9,544 injuries and Excessive Heat with a total number of 9,224 injuries.
##Creating objects that summarize the total fatalities and injuries by type of event and sorting the data frames by decreasing count.
fatal <- aggregate(FATALITIES~EVTYPE, data=data_clean, FUN=sum, na.rm=TRUE)
fatal_sorted <- fatal[order(-fatal$FATALITIES), ]
inj <- aggregate(INJURIES~EVTYPE, data=data_clean, FUN=sum, na.rm=TRUE)
inj_sorted <- inj[order(-inj$INJURIES), ]
##Picking the top 10 types of fatalities and injuries using the head function
top10fatal <- head(fatal_sorted, 10)
top10inj <- head(inj_sorted, 10)
##Creating plots to illustrate the effects of these types.
library(ggplot2)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
p1 <- ggplot(top10fatal, aes(x=reorder(EVTYPE, -FATALITIES), y=FATALITIES)) +
geom_col(fill="darkred") +
theme_bw() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs (title= "Top 10 US Weather Events by Total Fatalities",
x="Event Type",
y = "Number of Fatalities")
p2 <- ggplot(top10inj, aes(x=reorder(EVTYPE, -INJURIES), y=INJURIES)) +
geom_col(fill="darkblue") +
theme_bw() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs (title= "Top 10 US Weather Events by Total Injuries",
x="Event Type",
y = "Number of Injuries")
grid.arrange(p1, p2, ncol=2)
Figure 1: Top 10 weather events in the United States associated with the highest number of fatalities (left) and injuries (right).
We continued our analysis exploring any potential associaton between the different types of events and total economic damage to investigate the economic impact of these natural disasters. Total economic damage is the sum of total property damage and total crop damage. Similarly to our previous analysis, we gathered the total economic damage for each weather event type. We then sorted the list in a descending order and created a plot that illustrates the top 10 weather types that are associated with the highest economic deficit. Our analysis indicates that the natural disasters associated with the highest economic deficit are Floods with a total economic damage of $179,909,295,032 , followed by Hurricanes with a total economic damage of $90,872,527,810 and Tornadoes with a total economic damage of $57,352,114,049 .
##Creating objects that summarize the total Economic damage by type of event and sorting the data frames by decreasing count.
econ <- aggregate(Total_Economic_Damage~EVTYPE, data=data_clean, FUN=sum, na.rm=TRUE)
econ_sorted <- econ[order(-econ$Total_Economic_Damage), ]
##Picking the top 10 weathing types causing Economic Damage
top10econ <- head(econ_sorted, 10)
##Creating plots to illustrate the impact of these types.
library(ggplot2)
library(gridExtra)
ggplot(top10econ, aes(x=reorder(EVTYPE, -Total_Economic_Damage), y=Total_Economic_Damage)) +
geom_col(fill="gold") +
theme_bw() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs (title= "Top 10 US Weather Events by Total Economic Damage",
x="Event Type",
y = "Total Economic Damage in U.S. Dollars ($)")
Figure 2: Top 10 weather events in the United States associated with the greatest total economic damage (combined property and crop damage).