Analysis of U.S. sever weather events harmful to population health and the economy.

Synopsis:

In this report, I aimed to address the following questions: in the U.S., which severe weather event has the worst impact on the population health and which was most devastating financially. I have downloaded data from the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database obtaining all available years (1950-2011). To address the impact on population heath, I have determined the top 10 weather events resulting in the highest number of either fatalities or injuries. To address the impact on the economy, I have determined the top 10 weather events resulting in the highest value of either property or crop damages. Overall, it appears that with respect to population health, tornados have the largest impact. With respect to economic damage, tornados are the worst for property damage while droughts are the worst for crop damages.

library(gtools)
## Warning: package 'gtools' was built under R version 3.4.4
library(formatR)
library(knitr)
library(plyr)
library(ggplot2)
library(patchwork)
opts_chunk$set(tidy.opts=list(width.cutoff=80),tidy=TRUE)

Data Importing

if (!file.exists("./data")) {
    dir.create("./data")
}
fileUrl <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(fileUrl, destfile = "./data/storm.csv.bz2")

# Read the file into a variable called storm
storm <- read.csv("data/storm.csv.bz2")

Data Procesing

# For the following variables, calculate the total number per event type followed
# by ordering and extracting the top 10 rows: FATALITIES & INJURIES.
total_fatalities <- ddply(storm, c("EVTYPE"), summarise, sum = sum(FATALITIES))
total_fatalities <- total_fatalities[order(total_fatalities$sum, decreasing = T), 
    ][1:10, ]

total_injuries <- ddply(storm, c("EVTYPE"), summarise, sum = sum(INJURIES))
total_injuries <- total_injuries[order(total_injuries$sum, decreasing = T), ][1:10, 
    ]

# Correct the values for PROPDMGEXP of 'H', 'K', and 'M' to multiply the PROPDMG
# by 100, 1000, and 100000, respectively
storm$CorrectedValue <- ifelse(storm$PROPDMGEXP == "H", storm$PROPDMG * 100, ifelse(storm$PROPDMGEXP == 
    "K", storm$PROPDMG * 1000, ifelse(storm$PROPDMGEXP == "M", storm$PROPDMG * 1e+06, 
    "NA")))

# Coerce the values generated from the previous line of code into the numeric
# class
storm$CorrectedValue <- as.numeric(storm$CorrectedValue)
## Warning: NAs introduced by coercion
# For the following variables, calculate the total number per event type followed
# by ordering and extracting the top 10 rows: PROPDMG & CROPDMG
total_prop_damage <- ddply(storm, c("EVTYPE"), summarise, sum = sum(CorrectedValue, 
    na.rm = T))
total_prop_damage <- total_prop_damage[order(total_prop_damage$sum, decreasing = T), 
    ][1:10, ]


# Repeat the same process done above for the property damage data for the crop
# damage data
storm$CorrectedValue <- ifelse(storm$CROPDMGEXP == "H", storm$CROPDMG * 100, ifelse(storm$CROPDMGEXP == 
    "K", storm$CROPDMG * 1000, ifelse(storm$CROPDMGEXP == "M", storm$CROPDMG * 1e+06, 
    "NA")))

storm$CorrectedValue <- as.numeric(storm$CorrectedValue)
## Warning: NAs introduced by coercion
total_crop_damage <- ddply(storm, c("EVTYPE"), summarise, sum = sum(CorrectedValue, 
    na.rm = T))
total_crop_damage <- total_crop_damage[order(total_crop_damage$sum, decreasing = T), 
    ][1:10, ]

Results

Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?

# Top 10 fatalities plot
a <- ggplot(total_fatalities, aes(x = reorder(EVTYPE, -sum), y = sum))
a <- a + geom_bar(stat = "identity") + geom_text(aes(label = sum), vjust = -0.3, 
    size = 3.5) + labs(title = "Top 10 Severe Weather Events Impact on Fatalities", 
    x = "Weather Event Type", y = "Total Fatalaty Count") + theme_classic() + theme(axis.text.x = element_text(angle = 90, 
    vjust = 0.5), plot.title = element_text(hjust = 0.5))

# Top 10 injuries plot
b <- ggplot(total_injuries, aes(x = reorder(EVTYPE, -sum), y = sum))
b <- b + geom_bar(stat = "identity") + geom_text(aes(label = sum), vjust = -0.3, 
    size = 3.5) + labs(title = "Top 10 Severe Weather Events Impact on Injuries", 
    x = "Weather Event Type", y = "Total Injury Count") + theme_classic() + theme(axis.text.x = element_text(angle = 90, 
    vjust = 0.5), plot.title = element_text(hjust = 0.5))

# add both plots side by side using the patchwork package
a + b

Across the United States, which types of events have the greatest economic consequences?

# Top 10 property damaging events plot
a <- ggplot(total_prop_damage, aes(x = reorder(EVTYPE, -sum), y = sum))
a <- a + geom_bar(stat = "identity") + labs(title = "Top 10 Severe Weather Events Impact on Property Damage", 
    x = "Weather Event Type", y = "Total Property Damage Value ($)") + theme_classic() + 
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5), plot.title = element_text(hjust = 0.5))


# Top 10 crop damaging events plot
b <- ggplot(total_crop_damage, aes(x = reorder(EVTYPE, -sum), y = sum))
b <- b + geom_bar(stat = "identity") + labs(title = "Top 10 Severe Weather Events Impact on Crop Damage", 
    x = "Weather Event Type", y = "Total Crop Damage Value ($)") + theme_classic() + 
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5), plot.title = element_text(hjust = 0.5))

# add both plots side by side using the patchwork package
a + b