Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern. This project involves exploring the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. This database tracks characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of any fatalities, injuries, and property damage.
This analysis answers the following two questions: 1. Across the United States, which types of events are most harmful with respect to population health? 2. Across the United States, which types of events have the greatest economic consequences?
Variables analysed for the first question are fatalities and injuries. Variables analysed for the second question are property damage and crop damage.
if(!file.exists("/StormData.csv.bz2")){
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2",destfile="./StormData.csv.bz2")
}
StormData <- read.csv(bzfile("StormData.csv.bz2"), sep=",", header=T)
head(StormData)
## STATE__ BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE EVTYPE
## 1 1 4/18/1950 0:00:00 0130 CST 97 MOBILE AL TORNADO
## 2 1 4/18/1950 0:00:00 0145 CST 3 BALDWIN AL TORNADO
## 3 1 2/20/1951 0:00:00 1600 CST 57 FAYETTE AL TORNADO
## 4 1 6/8/1951 0:00:00 0900 CST 89 MADISON AL TORNADO
## 5 1 11/15/1951 0:00:00 1500 CST 43 CULLMAN AL TORNADO
## 6 1 11/15/1951 0:00:00 2000 CST 77 LAUDERDALE AL TORNADO
## BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END COUNTYENDN
## 1 0 0 NA
## 2 0 0 NA
## 3 0 0 NA
## 4 0 0 NA
## 5 0 0 NA
## 6 0 0 NA
## END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES INJURIES PROPDMG
## 1 0 14.0 100 3 0 0 15 25.0
## 2 0 2.0 150 2 0 0 0 2.5
## 3 0 0.1 123 2 0 0 2 25.0
## 4 0 0.0 100 2 0 0 2 2.5
## 5 0 0.0 150 2 0 0 2 2.5
## 6 0 1.5 177 2 0 0 6 2.5
## PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES LATITUDE LONGITUDE
## 1 K 0 3040 8812
## 2 K 0 3042 8755
## 3 K 0 3340 8742
## 4 K 0 3458 8626
## 5 K 0 3412 8642
## 6 K 0 3450 8748
## LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1 3051 8806 1
## 2 0 0 2
## 3 0 0 3
## 4 0 0 4
## 5 0 0 5
## 6 0 0 6
dim(StormData)
## [1] 902297 37
Since not all the columns are relevant to this analysis, I select the relevant columns.
StormData <- StormData[, c(8, 23:28)]
head(StormData)
## EVTYPE FATALITIES INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP
## 1 TORNADO 0 15 25.0 K 0
## 2 TORNADO 0 0 2.5 K 0
## 3 TORNADO 0 2 25.0 K 0
## 4 TORNADO 0 2 2.5 K 0
## 5 TORNADO 0 2 2.5 K 0
## 6 TORNADO 0 6 2.5 K 0
The new dataset of relevant variables includes:
I proceed to aggregate the fatalities and injuries by type of events and take a look at the top 20 events causing of injuries and fatalities
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
total_injuries <- aggregate(INJURIES ~ EVTYPE, data = StormData, FUN = sum)
total_injuries <- arrange(total_injuries, desc(INJURIES))
total_injuries <- total_injuries[1:20, ]
total_injuries
## EVTYPE INJURIES
## 1 TORNADO 91346
## 2 TSTM WIND 6957
## 3 FLOOD 6789
## 4 EXCESSIVE HEAT 6525
## 5 LIGHTNING 5230
## 6 HEAT 2100
## 7 ICE STORM 1975
## 8 FLASH FLOOD 1777
## 9 THUNDERSTORM WIND 1488
## 10 HAIL 1361
## 11 WINTER STORM 1321
## 12 HURRICANE/TYPHOON 1275
## 13 HIGH WIND 1137
## 14 HEAVY SNOW 1021
## 15 WILDFIRE 911
## 16 THUNDERSTORM WINDS 908
## 17 BLIZZARD 805
## 18 FOG 734
## 19 WILD/FOREST FIRE 545
## 20 DUST STORM 440
total_fatalities <- aggregate(FATALITIES ~ EVTYPE, data = StormData, FUN = sum)
total_fatalities <- arrange(total_fatalities, desc(FATALITIES))
total_fatalities <- total_fatalities[1:20, ]
total_fatalities
## EVTYPE FATALITIES
## 1 TORNADO 5633
## 2 EXCESSIVE HEAT 1903
## 3 FLASH FLOOD 978
## 4 HEAT 937
## 5 LIGHTNING 816
## 6 TSTM WIND 504
## 7 FLOOD 470
## 8 RIP CURRENT 368
## 9 HIGH WIND 248
## 10 AVALANCHE 224
## 11 WINTER STORM 206
## 12 RIP CURRENTS 204
## 13 HEAT WAVE 172
## 14 EXTREME COLD 160
## 15 THUNDERSTORM WIND 133
## 16 HEAVY SNOW 127
## 17 EXTREME COLD/WIND CHILL 125
## 18 STRONG WIND 103
## 19 BLIZZARD 101
## 20 HIGH SURF 101
Next, I need to convert property and crop damage into numbers where H=10^2, K=10^3, M =10^6, and B=10^9. For this, we create two new variables: PROPDAMAGE, CROPDAMAGE
StormData$PROPDAMAGE = 0
StormData[StormData$PROPDMGEXP == "H", ]$PROPDAMAGE = StormData[StormData$PROPDMGEXP == "H", ]$PROPDMG * 10^2
StormData[StormData$PROPDMGEXP == "K", ]$PROPDAMAGE = StormData[StormData$PROPDMGEXP == "K", ]$PROPDMG * 10^3
StormData[StormData$PROPDMGEXP == "M", ]$PROPDAMAGE = StormData[StormData$PROPDMGEXP == "M", ]$PROPDMG * 10^6
StormData[StormData$PROPDMGEXP == "B", ]$PROPDAMAGE = StormData[StormData$PROPDMGEXP == "B", ]$PROPDMG * 10^9
StormData$CROPDAMAGE = 0
StormData[StormData$CROPDMGEXP == "H", ]$CROPDAMAGE = StormData[StormData$CROPDMGEXP == "H", ]$CROPDMG * 10^2
StormData[StormData$CROPDMGEXP == "K", ]$CROPDAMAGE = StormData[StormData$CROPDMGEXP == "K", ]$CROPDMG * 10^3
StormData[StormData$CROPDMGEXP == "M", ]$CROPDAMAGE = StormData[StormData$CROPDMGEXP == "M", ]$CROPDMG * 10^6
StormData[StormData$CROPDMGEXP == "B", ]$CROPDAMAGE = StormData[StormData$CROPDMGEXP == "B", ]$CROPDMG * 10^9
I proceed to aggregate property and crop damage into one variable named economic damage and arrange and select the top 20.
economic_damage <- aggregate(PROPDAMAGE + CROPDAMAGE ~ EVTYPE, StormData, sum)
names(economic_damage) = c("EVENT_TYPE", "TOTAL_DAMAGE")
economic_damage <- arrange(economic_damage, desc(TOTAL_DAMAGE))
economic_damage <- economic_damage[1:20, ]
economic_damage$TOTAL_DAMAGE <- economic_damage$TOTAL_DAMAGE/10^9
economic_damage$EVENT_TYPE <- factor(economic_damage$EVENT_TYPE, levels = economic_damage$EVENT_TYPE)
head(economic_damage)
## EVENT_TYPE TOTAL_DAMAGE
## 1 FLOOD 150.31968
## 2 HURRICANE/TYPHOON 71.91371
## 3 TORNADO 57.34061
## 4 STORM SURGE 43.32354
## 5 HAIL 18.75290
## 6 FLASH FLOOD 17.56213
To show the results, I proceed to merge the fatalities and injuries into one data set and then make a barplot.
total_health<- merge(total_fatalities, total_injuries, by.x = "EVTYPE", by.y = "EVTYPE")
total_health<-arrange(total_health, desc(FATALITIES+INJURIES))
names_events <- total_health$EVTYPE
barplot(t(total_health[,-1]), names.arg = names_events, ylim = c(0,95000), beside = T, cex.names = 0.8, las=2, col = c("blue", "light green"), main="Top Weather Disaster Casualties")
legend("topright",c("Fatalities","Injuries"),fill=c("blue","light green"),bty = "n")
The Barplot ranks top weather disaster events that causes most population health harms. Evidence shows that Tornado has the hightest level of both Injuries and Fatalities.
with(economic_damage, barplot(TOTAL_DAMAGE, names.arg = EVENT_TYPE, beside = T, cex.names = 0.8, las=2, col = "Pink", main = "Total Economic Damage of Weather Disasters", ylab = "Total Damage in USD (10^9)"))
The plot shows that Floods have the greatest economic consequence.