In this report we look at the different storm and severe weather events reported by the National Oceanic and Atmospheric Administration (NOAA). We examine which event types are most harmful to public health in terms of fatalities and injuries. We also examine which event types have the greatest economic consequences in terms of property and crop damage.
The original data file, repdata-data-StormData.csv.bz2, is read into R using the read.csv() function, then the subset seven columns of interest to this analysis is taken. Then, all rows with no fatalities, injuries, or damages are removed, since we’ll be looking at sums in the analyses.
rawData <- read.csv('repdata-data-StormData.csv.bz2')
stormData <- subset(rawData,select=c("EVTYPE","FATALITIES","INJURIES","PROPDMG","PROPDMGEXP","CROPDMG","CROPDMGEXP"))
nonZero <- subset(stormData,FATALITIES > 0 | INJURIES > 0 | PROPDMG > 0 | CROPDMG >0)
nonZero <- droplevels(nonZero)
Next, the event types are cleaned up by grouping similar and misspelled categories.
cleanEV <- as.character(nonZero$EVTYPE)
cleanEV[grep("hurr|typhoon",nonZero$EVTYPE,ignore.case=T)]="HURRICANE"
cleanEV[grep("avalanc",nonZero$EVTYPE,ignore.case=T)]="AVALANCHE"
cleanEV[grep("blizzard",nonZero$EVTYPE,ignore.case=T)]="BLIZZARD"
cleanEV[grep("coastal flood",nonZero$EVTYPE,ignore.case=T)]="COASTAL FLD"
cleanEV[grep("freezing fog",nonZero$EVTYPE,ignore.case=T)]="FREEZING FG"
cleanEV[grep("fog",nonZero$EVTYPE,ignore.case=T)]="DENSE FOG"
cleanEV[grep("dust dev",nonZero$EVTYPE,ignore.case=T)]="DUST DEVIL"
cleanEV[grep("dust storm",nonZero$EVTYPE,ignore.case=T)]="DUST STORM"
cleanEV[grep("flash",nonZero$EVTYPE,ignore.case=T)]="FLASH FLD"
cleanEV[grep("lake.*flood",nonZero$EVTYPE,ignore.case=T)]="LAKESHORE FLD"
cleanEV[grep("flood",nonZero$EVTYPE,ignore.case=T)]="FLOOD"
cleanEV[grep("marine hail",nonZero$EVTYPE,ignore.case=T)]="MARINE HL"
cleanEV[grep("hail",nonZero$EVTYPE,ignore.case=T)]="HAIL"
cleanEV[grep("drought",nonZero$EVTYPE,ignore.case=T)]="DROUGHT"
cleanEV[grep("heat",nonZero$EVTYPE,ignore.case=T)]="HEAT"
cleanEV[grep("thunder|erstorm|tstm",nonZero$EVTYPE,ignore.case=T)]="THUNDERSTORM WND"
cleanEV[grep("torn",nonZero$EVTYPE,ignore.case=T)]="TORNADO"
cleanEV[grep("heavy rain|hvy rain|heavy shower",nonZero$EVTYPE,ignore.case=T)]="HEAVY RAIN"
cleanEV[grep("heavy snow",nonZero$EVTYPE,ignore.case=T)]="HEAVY SNOW"
cleanEV[grep("lake.*snow",nonZero$EVTYPE,ignore.case=T)]="LAKE EFFECT SNW"
cleanEV[grep("high wind",nonZero$EVTYPE,ignore.case=T)]="HIGH WIND"
cleanEV[grep("tropical storm",nonZero$EVTYPE,ignore.case=T)]="TROPICAL STORM"
cleanEV[grep("wild.*fire",nonZero$EVTYPE,ignore.case=T)]="WILDFIRE"
cleanEV[grep("rip curr",nonZero$EVTYPE,ignore.case=T)]="RIP CURRENT"
cleanEV[grep("wind",nonZero$EVTYPE,ignore.case=T)]="HIGH WIND"
cleanEV[grep("waterspout",nonZero$EVTYPE,ignore.case=T)]="WATERSPOUT"
cleanEV[grep("winter weather|wintry",nonZero$EVTYPE,ignore.case=T)]="WINTER WEATHER"
cleanEV[grep("winter storm",nonZero$EVTYPE,ignore.case=T)]="WINTER STORM"
cleanEV[grep("ice storm",nonZero$EVTYPE,ignore.case=T)]="ICE STORM"
cleanEV[grep("snow",nonZero$EVTYPE,ignore.case=T)]="HEAVY SNOW"
cleanEV[grep("tning",nonZero$EVTYPE,ignore.case=T)]="LIGHTNING"
cleanEV[grep("surf|swells",nonZero$EVTYPE,ignore.case=T)]="HEAVY SURFF"
cleanEV[grep("extreme cold",nonZero$EVTYPE,ignore.case=T)]="EXTREME CLD"
cleanEV[grep("cold",nonZero$EVTYPE,ignore.case=T)]="COLD"
cleanEV <- as.factor(cleanEV)
cleanEV <- droplevels(cleanEV)
Next, clean up the estimates of damage by combining the information in the exponent variables with the damage variables.
cleanPropExp <- as.character(nonZero$PROPDMGEXP)
cleanPropExp[cleanPropExp==""|cleanPropExp=="+"|cleanPropExp=="-"]="0"
cleanPropExp[cleanPropExp=="H"|cleanPropExp=="h"]="2"
cleanPropExp[cleanPropExp=="K"|cleanPropExp=="k"]="3"
cleanPropExp[cleanPropExp=="M"|cleanPropExp=="m"]="6"
cleanPropExp[cleanPropExp=="B"|cleanPropExp=="b"]="9"
cleanPropExp <- as.numeric(cleanPropExp)
propEst <- nonZero$PROPDMG*10^cleanPropExp
cleanCropExp <- as.character(nonZero$CROPDMGEXP)
cleanCropExp[cleanCropExp==""|cleanCropExp=="?"]="0"
cleanCropExp[cleanCropExp=="K"|cleanCropExp=="k"]="3"
cleanCropExp[cleanCropExp=="M"|cleanCropExp=="m"]="6"
cleanCropExp[cleanCropExp=="B"|cleanCropExp=="b"]="9"
cleanCropExp <- as.numeric(cleanCropExp)
cropEst <- nonZero$CROPDMG*10^cleanCropExp
par(mfrow=c(1,2),mar=c(6,2,2,2))
injuries <- aggregate(nonZero$INJURIES,by=list(cleanEV),sum)
injuries <- injuries[order(injuries[,2],decreasing=T),]
bp <- barplot(injuries[1:10,2],xaxt="n",main="Highest Injuries\nby Event Type")
text(y=par("usr")[3],x=bp,labels = as.character(injuries[1:10,1]),srt=55,adj=1,xpd=T)
fatalities <- aggregate(nonZero$FATALITIES,by=list(cleanEV),sum)
fatalities <- fatalities[order(fatalities[,2],decreasing=T),]
bp <- barplot(fatalities[1:10,2],xaxt="n",main="Highest Fatalities\nby Event Type")
text(y=par("usr")[3],x=bp,labels = as.character(fatalities[1:10,1]),srt=55,adj=1,xpd=T)
The five most harmful event types with respect to population health (injuries and fatalities) are TORNADO, HEAT, FLOOD, HIGH WIND, LIGHTNING
par(mfrow=c(1,2),mar=c(6,4,2,2))
propDamages <- aggregate(propEst,by=list(cleanEV),sum)
propDamages <- propDamages[order(propDamages[,2],decreasing=T),]
bp <- barplot(propDamages[1:10,2],xaxt="n",main="Highest Property Damages\nby Event Type",ylab="Dollars")
text(y=par("usr")[3],x=bp,labels = as.character(propDamages[1:10,1]),srt=55,adj=1,xpd=T)
cropDamages <- aggregate(cropEst,by=list(cleanEV),sum)
cropDamages <- cropDamages[order(cropDamages[,2],decreasing=T),]
bp <- barplot(cropDamages[1:10,2],xaxt="n",main="Highest Crop Damages\nby Event Type",ylab="Dollars")
text(y=par("usr")[3],x=bp,labels = as.character(cropDamages[1:10,1]),srt=55,adj=1,xpd=T)
par(mar=c(6,4,2,2))
totEst <- propEst + cropEst
totDamages <- aggregate(totEst,by=list(cleanEV),sum)
totDamages <- totDamages[order(totDamages[,2],decreasing=T),]
bp <- barplot(totDamages[1:10,2],xaxt="n",main="Highest Total Damages by Event Type",ylab="Dollars")
text(y=par("usr")[3],x=bp,labels = as.character(totDamages[1:10,1]),srt=55,adj=1,xpd=T)
The five most harmful event types differ between property damages and crop damages. In terms of total damages, the top five most harmful event types with respect to economic consequences are FLOOD, HURRICANE, TORNADO, STORM SURGE, HIGH WIND