This is an analysis of the damage caused by severe weather events. This analysis finds the event types that are most harmful with respect to population health, as measured by total number of fatalities and injures. In addition, the events that have the greatest economic consequences are also shown, as measured by the total amount of combined property and crop damage caused.
Firstly the storm CSV file is loaded using the read.csv R function. Some additional processing is then applied to determine the total property and crop damage. In order to determine the true property damage, we need to use both the PROPDMG (which lists a value) and the PROPDMGEXP (which stores whether PROPDMG is in millions, thousands, or as listed). The same is true for CROPDMG. A summary data table is then created listing the total fatalities, injuries, and damage by event type.
library(ggplot2)
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
storm <-read.csv("storm.bz2")
storm$PROPDMGNEW <-ifelse(toupper(storm$PROPDMGEXP)=="M",storm$PROPDMG*1000000,
(ifelse(toupper(storm$PROPDMGEXP)=="K",storm$PROPDMG*1000,
storm$PROPDMG)))
storm$CROPDMGNEW <-ifelse(toupper(storm$CROPDMGEXP)=="M",storm$CROPDMG*1000000,
(ifelse(toupper(storm$CROPDMGEXP)=="K",storm$CROPDMG*1000,
storm$CROPDMG)))
storm$TOTDMG <-storm$CROPDMGNEW + storm$PROPDMGNEW
storm_sum <- summarise(group_by(storm,EVTYPE),tot_inj = sum(INJURIES)
,tot_fat = sum(FATALITIES)
,totdmgsum = sum(TOTDMG)/1000000
,count=n())
The first graph shows the total number of fatalities by event type, for the 10 events with the highest total number of fatalities.
storm_sum <- arrange(storm_sum,desc(tot_fat))
top_10_storm_fat <- head(storm_sum,n=10)
top_10_storm_fat$EVTYPE <- factor(top_10_storm_fat$EVTYPE, levels = top_10_storm_fat$EVTYPE[order(desc(top_10_storm_fat$tot_fat))])
q<-ggplot(data=top_10_storm_fat, aes( y=tot_fat,x=EVTYPE)) +
geom_col() +
labs(x="Event type",y="Total fatalities",title="Total fatalities by event type")+
theme(axis.text.x = element_text(angle = 90, hjust = 1))
q
The second graph shows the total number of injuries by event type, for the 10 events with the highest total number of injuries.
storm_sum <- arrange(storm_sum,desc(tot_inj))
top_10_storm_inj <- head(storm_sum,n=10)
top_10_storm_inj$EVTYPE <- factor(top_10_storm_inj$EVTYPE, levels = top_10_storm_inj$EVTYPE[order(desc(top_10_storm_inj$tot_inj))])
q<-ggplot(data=top_10_storm_inj, aes( y=tot_inj,x=EVTYPE))+
geom_col() +
labs(x="Event type",y="Total injuries",title="Total injuries by event type")+
theme(axis.text.x = element_text(angle = 90, hjust = 1))
q
The third graph shows the total amount of property and crop damage (in millions) by event type, for the 10 events with the highest total amount of combined property and crop damage.
storm_sum <- arrange(storm_sum,desc(totdmgsum))
top_10_storm_dmg <- head(storm_sum,n=10)
top_10_storm_dmg$EVTYPE <- factor(top_10_storm_dmg$EVTYPE, levels = top_10_storm_dmg$EVTYPE[order(desc(top_10_storm_dmg$totdmgsum))])
q<-ggplot(data=top_10_storm_dmg, aes( y=totdmgsum,x=EVTYPE)) +
geom_col() +
labs(x="Event type",y="Total damage (m)",title="Total damage by event type")+
theme(axis.text.x = element_text(angle = 90, hjust = 1))
q