Synopsis

The purpose of this analysis is to examine the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. Specifically, the effect of different types of weather events on population health and the economy were explored. For population health, the effect of these events on the number of fatalities and injuries was explored. For economic impact, the amount of crop and property damage per event type has been assessed.

# no code needed for this section

Data Processing

The data for this analysis was downloaded from the following URL: https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2

The file was downloaded and read into R with the code below.

URL <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(URL, destfile = "storm.csv")
storm <- read.csv("storm.csv")

After downloading the data some transformations needed to be made. Specifically, the crop and property damage fields were not intuitive. Each of these items had the amount (Ex: 5) in one column and the multiplier (thousands, millions, etc.) in another column. These two fields were combined into one field that contained the total crop or property damage, as displayed in the code below.

library(plyr)

storm$CROPDMGEXPnew <- as.numeric(as.character(mapvalues(storm$CROPDMGEXP, from = c("h", "H", "k", "K", "m", "M", "B"), to = c(2, 2, 3, 3, 6, 6, 9))))
## The following `from` values were not present in `x`: h, H
## Warning: NAs introduced by coercion
storm$PROPDMGEXPnew <- as.numeric(as.character(mapvalues(storm$PROPDMGEXP, from = c("h", "H", "k", "K", "m", "M", "B"), to = c(2, 2, 3, 3, 6, 6, 9))))
## The following `from` values were not present in `x`: k
## Warning: NAs introduced by coercion
storm$CROPDMGtotal <- storm$CROPDMG*(10^storm$CROPDMGEXPnew)
storm$PROPDMGtotal <- storm$PROPDMG*(10^storm$PROPDMGEXPnew)

Finally, the data was aggregated to compare the number of adverse events (fatalities, injuries, crop damage and property damage) by event type. After aggregating, we sort the data by descending impact, and pull out the top 3 factors for each outcome to examine in more detail.

fatalities <- data.frame(aggregate(FATALITIES ~ EVTYPE, storm, sum))
injuries <- data.frame(aggregate(INJURIES ~ EVTYPE, storm, sum))

cropdamage <- data.frame(aggregate(CROPDMGtotal ~ EVTYPE, storm, sum))
propdamage <- data.frame(aggregate(PROPDMGtotal ~ EVTYPE, storm, sum))

fatalities <- fatalities[order(-fatalities$FATALITIES),]
injuries <- injuries[order(-injuries$INJURIES),]
propdamage <- propdamage[order(-propdamage$PROPDMGtotal),]
cropdamage <- cropdamage[order(-cropdamage$CROPDMGtotal),]

fatalitiestop5 <- fatalities[1:3,]
injuriestop5 <- injuries[1:3,]
propdamagetop5 <- propdamage[1:3,]
cropdamagetop5 <- cropdamage[1:3,]

Results

Plotting the top three factors for each of the outcomes (fatalities, injuries, crop damage, and property damage) shows us the areas with the largest adverse impact. For population health, it is seen below that tornados have by far the largest impact. For economic consequences, droughts and floods have the largest impact on crops and property, respectively.

library(ggplot2, lib.loc = "H:/Decision Support/Stats Jam/R files/Libraries")
library(gridExtra, lib.loc = "H:/Decision Support/Stats Jam/R files/Libraries")

fatalitiesplot <- ggplot(data = fatalitiestop5, aes(x = EVTYPE, y = FATALITIES)) + geom_bar(stat = "identity", fill = "darkblue") + labs(x = "Event Type", y = "Fatalities")
injuriesplot <- ggplot(data = injuriestop5, aes(x = EVTYPE, y = INJURIES)) + geom_bar(stat = "identity", fill = "darkblue") + labs(x = "Event Type", y = "Injuries")
grid.arrange(fatalitiesplot, injuriesplot, ncol = 2)

cropplot <- ggplot(data = cropdamagetop5, aes(x = EVTYPE, y = CROPDMGtotal)) + geom_bar(stat = "identity", fill = "darkblue") + labs(x = "Event Type", y = "Crop Damage")
propplot <- ggplot(data = propdamagetop5, aes(x = EVTYPE, y = PROPDMGtotal)) + geom_bar(stat = "identity", fill = "darkblue") + labs(x = "Event Type", y = "Property Damage")
grid.arrange(cropplot, propplot, ncol = 2)