Analysis of damage caused by severe weather events across the United States

Synopsis

This analysis is to answer the question which severe weather events caused the most damage to health of population and economy. As first step, the data downloaded is subsetted to EVTYPE, FATALITIES and INJURIES three columns. The event type which has largest number of fatalities and injuries are founded. Both are TORNADO. To compare it with other types, top ten of most severe events with respect to fatalities and injuries are ploted. Same procedure is applied to economic loss except EVTYPE, PROPDMG and CROPDMG are selected. The event caused the most damage to property is FLOOD while to crop is DROUGHT.

Data processing

Assuming the data set downloaded from website is already under the same directory as this R Markdown file, it is loaded as data frame with read.csv.

StormDF <- read.csv("repdata_data_StormData.csv", sep = ",", header = TRUE)

Events that caused most injuries and fatalities

LifeDMGsubset <- StormDF[,c("EVTYPE", "FATALITIES", "INJURIES")]
LifeAggdata <-aggregate(cbind(LifeDMGsubset$FATALITIES, LifeDMGsubset$INJURIES), list(levels(LifeDMGsubset$EVTYPE)[LifeDMGsubset$EVTYPE]), sum, na.rm=TRUE)
names(LifeAggdata) <- c("EVTYPE", "FATALITIES", "INJURIES")

Events that caused greatest economic consequences

magChar <- c("^$|[-?+]|0", "1", "2|[Hh]", "3|[Kk]", "4", "5", "6|[Mm]", "7", "8", "[Bb]")
for (i in 1:length(magChar)){
  if (length(grep(magChar[i], StormDF$PROPDMGEXP)) != 0) {
    StormDF[grep(magChar[i], StormDF$PROPDMGEXP), "PROPDMG"] <- StormDF[grep(magChar[i], StormDF$PROPDMGEXP), "PROPDMG"] * 10^(i-1)
  }
}
for (i in 1:length(magChar)){
  if (length(grep(magChar[i], StormDF$CROPDMGEXP)) != 0) {
    StormDF[grep(magChar[i], StormDF$CROPDMGEXP), "CROPDMG"] <- StormDF[grep(magChar[i], StormDF$CROPDMGEXP), "CROPDMG"] * 10^(i-1)
  }
}
EcoDMGsubset <- StormDF[,c("EVTYPE", "PROPDMG", "CROPDMG")]
EcoAggdata <-aggregate(cbind(EcoDMGsubset$PROPDMG, EcoDMGsubset$CROPDMG), list(levels(EcoDMGsubset$EVTYPE)[EcoDMGsubset$EVTYPE]), sum, na.rm=TRUE)
names(EcoAggdata) <- c("EVTYPE", "PROPDMG", "CROPDMG")

Results

Event that caused most injuries and fatalities

LifeAggdata[LifeAggdata$INJURIES==max(LifeAggdata$INJURIES),]
##      EVTYPE FATALITIES INJURIES
## 834 TORNADO       5633    91346
LifeAggdata[LifeAggdata$FATALITIES==max(LifeAggdata$FATALITIES),]
##      EVTYPE FATALITIES INJURIES
## 834 TORNADO       5633    91346

Top ten of most severe events are plotted both for injuries and for fatalities

sortInj <- LifeAggdata[order(-LifeAggdata$INJURIES),c("EVTYPE", "INJURIES")]
topTenInj <- sortInj[1:10, ]
topTenInj$EVTYPE <- factor(topTenInj$EVTYPE, levels = topTenInj$EVTYPE)
sortFat <- LifeAggdata[order(-LifeAggdata$FATALITIES),c("EVTYPE", "FATALITIES")]
topTenFat <- sortFat[1:10, ]
topTenFat$EVTYPE <- factor(topTenFat$EVTYPE, levels = topTenFat$EVTYPE)
par(mfrow = c(2, 1), mar = c(4, 4, 1, 1), mgp = c(2, 1, 0), cex.lab = 0.6, cex.axis = 0.5, xaxt = "n")
plot(topTenInj$EVTYPE, topTenInj$INJURIES, type = "s", xlab = "", ylab = "Number of injuries")
text(1:10, par("usr")[1], labels=topTenInj$EVTYPE, srt=45, pos=1, offset=2.0, xpd=TRUE, cex = 0.5)
plot(topTenFat$EVTYPE, topTenFat$FATALITIES, type = "s", xlab = "", ylab = "Number of fatalities")
text(1:10, par("usr")[1], labels=topTenFat$EVTYPE, srt=45, pos=1, offset=2.0, xpd=TRUE, cex = 0.5)

plot of chunk unnamed-chunk-6

Events that caused greatest economic consequences

EcoAggdata[EcoAggdata$PROPDMG==max(EcoAggdata$PROPDMG),]
##     EVTYPE   PROPDMG   CROPDMG
## 170  FLOOD 1.447e+11 5.662e+09
EcoAggdata[EcoAggdata$CROPDMG==max(EcoAggdata$CROPDMG),]
##     EVTYPE   PROPDMG   CROPDMG
## 95 DROUGHT 1.046e+09 1.397e+10

Top ten of most severe events are plotted both for property and for crop

sortProp <- EcoAggdata[order(-EcoAggdata$PROPDMG),c("EVTYPE", "PROPDMG")]
topTenProp <- sortProp[1:10, ]
topTenProp$EVTYPE <- factor(topTenProp$EVTYPE, levels = topTenProp$EVTYPE)
sortCrop <- EcoAggdata[order(-EcoAggdata$CROPDMG),c("EVTYPE", "CROPDMG")]
topTenCrop <- sortCrop[1:10, ]
topTenCrop$EVTYPE <- factor(topTenCrop$EVTYPE, levels = topTenCrop$EVTYPE)
par(mfrow = c(2, 1), mar = c(4, 4, 1, 1), mgp = c(2, 1, 0), cex.lab = 0.6, cex.axis = 0.5, xaxt = "n")
plot(topTenProp$EVTYPE, topTenProp$PROPDMG, type = "s", xlab = "", ylab = "Property damage in USD")
text(1:10, par("usr")[1], labels=topTenProp$EVTYPE, srt=45, pos=1, offset=2.0, xpd=TRUE, cex = 0.5)
plot(topTenCrop$EVTYPE, topTenCrop$CROPDMG, type = "s", xlab = "", ylab = "Crop damage in USD")
text(1:10, par("usr")[1], labels=topTenCrop$EVTYPE, srt=45, pos=1, offset=2.0, xpd=TRUE, cex = 0.5)

plot of chunk unnamed-chunk-9