An examination of NOAA data on weather events shows that Tornados have the largest health impact, as defined as total causalities. Floods had the largest impact in economic terms, defined as the sum of crop and property damage associated with a weather event. The leading causes of damages in each category also cause substantial damage in the other category. Flooding is the third largest cause of causalities, and tornados are the third largest cause of economic damage.
Load data. Read.csv is capable of uncompressing the data.
stormDat <- read.csv("repdata_data_StormData.csv.bz2")
head(stormDat)
## STATE__ BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1 1 4/18/1950 0:00:00 0130 CST 97 MOBILE AL
## 2 1 4/18/1950 0:00:00 0145 CST 3 BALDWIN AL
## 3 1 2/20/1951 0:00:00 1600 CST 57 FAYETTE AL
## 4 1 6/8/1951 0:00:00 0900 CST 89 MADISON AL
## 5 1 11/15/1951 0:00:00 1500 CST 43 CULLMAN AL
## 6 1 11/15/1951 0:00:00 2000 CST 77 LAUDERDALE AL
## EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END
## 1 TORNADO 0 0
## 2 TORNADO 0 0
## 3 TORNADO 0 0
## 4 TORNADO 0 0
## 5 TORNADO 0 0
## 6 TORNADO 0 0
## COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1 NA 0 14.0 100 3 0 0
## 2 NA 0 2.0 150 2 0 0
## 3 NA 0 0.1 123 2 0 0
## 4 NA 0 0.0 100 2 0 0
## 5 NA 0 0.0 150 2 0 0
## 6 NA 0 1.5 177 2 0 0
## INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1 15 25.0 K 0
## 2 0 2.5 K 0
## 3 2 25.0 K 0
## 4 2 2.5 K 0
## 5 2 2.5 K 0
## 6 6 2.5 K 0
## LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1 3040 8812 3051 8806 1
## 2 3042 8755 0 0 2
## 3 3340 8742 0 0 3
## 4 3458 8626 0 0 4
## 5 3412 8642 0 0 5
## 6 3450 8748 0 0 6
Process and aggregate health data. Causalities are defined as the sum of fatalities and injuries.
stormDat$Causalties <- stormDat$FATALITIES + stormDat$INJURIES
#Aggregate health impact data
HealthDat<- as.data.frame(tapply(stormDat$Causalties, stormDat$EVTYPE, sum))
colnames(HealthDat) <- "Casualties"
HealthDat$Fatalities <- tapply(stormDat$FATALITIES, stormDat$EVTYPE, sum)
HealthDat$Injuries <- tapply(stormDat$INJURIES, stormDat$EVTYPE, sum)
#Find top 10 weather events by descending sort and selecting top 10 rows
HealthDat <- HealthDat[order(-HealthDat$Casualties), ]
HealthDat <- HealthDat[ 1:10,]
#Use rbind to reshape data for plotting
healthBarDat <- rbind(HealthDat$Fatalities, HealthDat$Injuries)
Process and aggregate economic data. Damages are defined as the sum of property and crop damage. Raw data are transformed into dollar values by multiplying data by 10 to the given exponent.
#Create multplier variable based on non-standardized exponents
stormDat$multi <- 10^(stormDat$PROPDMGEXP)
## Warning in Ops.factor(10, (stormDat$PROPDMGEXP)): '^' not meaningful for
## factors
stormDat$multi[stormDat$PROPDMGEXP == "H" | stormDat$PROPDMGEXP == "h" ] <- 100
stormDat$multi[stormDat$PROPDMGEXP == "K" | stormDat$PROPDMGEXP == "k" ] <- 1000
stormDat$multi[stormDat$PROPDMGEXP == "M" | stormDat$PROPDMGEXP == "m" ] <- 1000000
stormDat$multi[stormDat$PROPDMGEXP == "B" | stormDat$PROPDMGEXP == "b" ] <- 1000000000
stormDat$multi[is.na(stormDat$multi)] <- 1
stormDat$cleanProp <- stormDat$PROPDMG * stormDat$multi
stormDat$multiC <- 10^(stormDat$CROPDMGEXP)
## Warning in Ops.factor(10, (stormDat$CROPDMGEXP)): '^' not meaningful for
## factors
stormDat$multiC[stormDat$CROPDMGEXP == "H" | stormDat$CROPDMGEXP == "h" ] <- 100
stormDat$multiC[stormDat$CROPDMGEXP == "K" | stormDat$CROPDMGEXP == "k" ] <- 1000
stormDat$multiC[stormDat$CROPDMGEXP == "M" | stormDat$CROPDMGEXP == "m" ] <- 1000000
stormDat$multiC[stormDat$CROPDMGEXP == "B" | stormDat$CROPDMGEXP == "b" ] <- 1000000000
stormDat$multiC[is.na(stormDat$multiC)] <- 1
stormDat$cleanCrop <- stormDat$CROPDMG * stormDat$multiC
#Aggregate economic damage data
dmgDat <- as.data.frame(tapply(stormDat$cleanCrop, stormDat$EVTYPE, sum))
colnames(dmgDat) <- "Crop"
dmgDat$Prop <- tapply(stormDat$cleanProp, stormDat$EVTYPE, sum)
dmgDat$totalDMG <- dmgDat$Crop + dmgDat$Prop
#Find top 10 weather events by descending sort and selecting top 10 rows
dmgDat <- dmgDat[order(-dmgDat$totalDMG), ]
dmgDat <- dmgDat[ 1:10,]
#Use rbind to reshape data for plotting
dmgBarDat <- rbind(dmgDat$Prop, dmgDat$Crop)
Tornados causes the most overall causalties, and the most injuries and fatalities.
barplot(healthBarDat, main="Top 10 Weather Event Causes of Causalties", col=c("darkblue","red"),
legend = c("Fatalities", "Injuries"), ylab="Causalties (Fatalities+Injuries)", cex.names=1, las=3)
Overall, flooding causes the most total and property damage. Drought causes the most crop damage.
barplot(dmgBarDat, main="Top 10 Weather Event Causes of Economic Damage", col=c("darkblue","green"),
legend = c("Property", "Crop"), ylab="Cost of Damage (Property+Crop)", cex.names=1, las=3)