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
if (!file.exists("StormData.csv.bz2")){
data_url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(data_url, "StormData.csv.bz2")
}
StormData <- read.csv("StormData.csv.bz2")
Event <- StormData %>% group_by(EVTYPE) %>% summarise(injuries = sum(INJURIES), deaths = sum(FATALITIES))
Event <- filter(Event, injuries>0 | deaths>0)
EvType <- filter(Event, deaths == max(Event$deaths))
Econ <- StormData %>% group_by(EVTYPE, PROPDMG, PROPDMGEXP) %>% summarise(damage = sum(PROPDMG))
Econ <- filter(Econ, damage>0)
Econ <- if(Econ$PROPDMGEXP == "K") {
mutate(Econ, damage = damage*10^3)
} else if(Econ$PROPDMGEXP == "M") {
mutate(Econ, damage = damage*10^6)
} else if(Econ$PROPDMGEXP == "B") {
mutate(Econ, damage = damage*10^9)
}
## Warning in if (Econ$PROPDMGEXP == "K") {: the condition has length > 1 and
## only the first element will be used
EcType <- filter(Econ, damage == max(Econ$damage))
The morbidity and mortality of the different storm types are presented in the two figures. It is clear upon looking at them that there is one particular storm datum that stands out above the rest, and this is the same storm type in both the morbidity and mortality bar plots. Upon further investigation, the maximum number of injuries was found to be 9.134610^{4}, and the maximum number of deaths, 5633; both much greater than any other Event Type, and were a result of TORNADO.
The Disaster Event with the maximum economic impact was TORNADO, with an impact of 1.66110^{9} dollars.
par(mfrow = c(1,2))
with(Event, barplot(Event$injuries, xlab = "Storms by Type (unnamed)", ylab = "Number of Injuries"))
with(Event, barplot(Event$deaths, xlab = "Storms by Type (unnamed)", ylab = "Number of Deaths"))