This Analysis looks to evaluate the varying impacts of different types of storms, from both a Population Health perspective and Economic perspective.
Based on the graphs below, Tornados and Floods seem to be the most harmful type of storm. Tornados accounted for the most fatalities and Floods accounted for the most property damage.
Load Data and call it “storm”
storm <- read.csv("C:/Users/A42512/Documents/1-1/Training/Data Science Foundations using R Specialization/Part 5 - Reproducible Research/Course Project 2/repdata_data_StormData.csv.bz2")
head(storm)
## 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
TotalFatalities <- aggregate(storm$FATALITIES, by=list(EventType = storm$EVTYPE), FUN = sum) #get the total fatalities by Event Type
OrderedTotalFatalities <- TotalFatalities[order(TotalFatalities$x, decreasing = TRUE),] #order the total fatalities, highest to lowest
Top6TotalFatalities <- head(OrderedTotalFatalities) #the top 6 event types based on total fatalities
library(ggplot2)
ggplot(data = Top6TotalFatalities, aes(x=reorder(EventType, -x), y = x)) + geom_bar(stat="identity", fill="steelblue") + geom_text(aes(label=format(x, big.mark=","), vjust=1.5)) + ggtitle("Top 6 Event Types based on Total Fatalities") + labs(x="Event Type", y="Fatalities")
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
storm2 <- storm %>% mutate(PropertyDamage = case_when(
PROPDMGEXP == "h" ~ PROPDMG * 100,
PROPDMGEXP == "K" ~ PROPDMG * 1000,
PROPDMGEXP == "M" ~ PROPDMG * 1000000,
PROPDMGEXP == "B" ~ PROPDMG * 1000000000,
TRUE ~ PROPDMG
)) #convert the property damage to a dollar amount, utilizing the money sign label
TotalPropertyDamage <- aggregate(storm2$PropertyDamage, by=list(EventType = storm2$EVTYPE), FUN = sum) #get the total property damage by event type
OrderedTotalPropertyDamage <- TotalPropertyDamage[order(TotalPropertyDamage$x, decreasing = TRUE),] #order the property damage highest to lowest
Top6TotalPropertyDamage <- head(OrderedTotalPropertyDamage) #the top 6 event types based on property damage
ggplot(data = Top6TotalPropertyDamage, aes(x=reorder(EventType, -x), y = x)) + geom_bar(stat="identity", fill="steelblue") + geom_text(aes(label=format(x, big.mark = ","), vjust=-0.4)) + ggtitle("Top 6 Event Types based on Total Property Damage") + labs(x="Event Type", y="Property Damage")