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 data analysis will address the following questions:
Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?
Across the United States, which types of events have the greatest economic consequences?
The Storm Data is obtained from the U.S. National Oceanic and Atmospheric Administration’s (NOAA) Storm Database.
The file is a Comma Separated Value (.csv) format, so we read it with the specific function read.csv().
stormData <- read.csv("repdata_data_StormData.csv")
Preview the data
head(stormData)
## 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
To see which events are the most harmful with respect to population health we need to aggregate() the data per event and do the sum of fatalities in one column and injuries in another column.
maxHarmEv <- aggregate(x = list(FATALITIES = stormData$FATALITIES,
INJURIES = stormData$INJURIES),
by = list(EVENT = stormData$EVTYPE),
FUN = sum)
We can also remove the events with zero values in the FATALITIES and INJURIES column.
maxHarmEv <- maxHarmEv[maxHarmEv$FATALITIES + maxHarmEv$INJURIES != 0, ]
head(maxHarmEv)
## EVENT FATALITIES INJURIES
## 18 AVALANCE 1 0
## 19 AVALANCHE 224 170
## 29 BLACK ICE 1 24
## 30 BLIZZARD 101 805
## 42 blowing snow 1 1
## 44 BLOWING SNOW 1 13
Let’s see now a brief summary of the data for fatalities and injuries of the events that have caused at least one dead or injured.
summary(maxHarmEv$FATALITIES)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 1.00 2.00 68.84 10.25 5633.00
summary(maxHarmEv$INJURIES)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 0.00 2.00 638.80 35.25 91350.00
To show the most harmful events with respect to population health I decided to subset again the data removing the events with fatalities or injuries smaller than the respective mean (68.84 for fatalities and 638.80 for injuries).
fataData <- maxHarmEv[maxHarmEv$FATALITIES >= mean(maxHarmEv$FATALITIES), 1:2]
injuData <- maxHarmEv[maxHarmEv$INJURIES >= mean(maxHarmEv$INJURIES), c(1,3)]
And we sort the data in descending order.
fataData <- fataData[order(-fataData$FATALITIES), ]
injuData <- injuData[order(-injuData$INJURIES), ]
The data is ready, the result will be exposed in the next section. Now we are going to elaborate the data to understand which types of events have the greatest economic consequences.
Damages are divided in two categories: damages to properties and damages to crops.
For properties there are two important column PROPDMG and PROPDMGEXP. The first one is in dollar unit, the second one has three values: “K” for thousands, “M” for millions, and “B” for billions. We decided to multiply the first column for the respective unit.
econDmg <- stormData
econDmg <- econDmg[, which(names(econDmg) %in% c("EVTYPE", "PROPDMG", "PROPDMGEXP", "CROPDMG", "CROPDMGEXP"))]
econDmg[econDmg$PROPDMGEXP == "K", ]$PROPDMG =
econDmg[econDmg$PROPDMGEXP == "K", ]$PROPDMG * 10^3
econDmg[econDmg$PROPDMGEXP == "M", ]$PROPDMG =
econDmg[econDmg$PROPDMGEXP == "M", ]$PROPDMG * 10^6
econDmg[econDmg$PROPDMGEXP == "B", ]$PROPDMG =
econDmg[econDmg$PROPDMGEXP == "B", ]$PROPDMG * 10^9
The same is apply to the crop damages, in this case the relevant columns are CROPDMG and CROPDMGEXP.
econDmg[econDmg$CROPDMGEXP == "K", ]$CROPDMG =
econDmg[econDmg$CROPDMGEXP == "K", ]$CROPDMG * 10^3
econDmg[econDmg$CROPDMGEXP == "M", ]$CROPDMG =
econDmg[econDmg$CROPDMGEXP == "M", ]$CROPDMG * 10^6
econDmg[econDmg$CROPDMGEXP == "B", ]$CROPDMG =
econDmg[econDmg$CROPDMGEXP == "B", ]$CROPDMG * 10^9
To obtain the total damage we aggregate the datasets and we do the sum of the crop damages and property damages.
econDmg <- aggregate(x = list(TOTDMG = econDmg$PROPDMG + econDmg$CROPDMG),
by = list(EVENT = econDmg$EVTYPE),
FUN = sum)
We can also remove the values equal to zero.
econDmg <- econDmg[econDmg$TOTDMG != 0, ]
Based on the method we applied earlier, we are going to expose a brief summary and we are going to subset the events that caused a damage bigger than the mean value.
summary(econDmg$TOTDMG)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000e+00 1.500e+04 2.215e+05 1.105e+09 6.188e+06 1.503e+11
econDmg <- econDmg[econDmg$TOTDMG >= mean(econDmg$TOTDMG), ]
And now we sort the data in descending order.
econDmg <- econDmg[order(-econDmg$TOTDMG), ]
After the elaboration of the data we are going to expose our result with a barplot.
par(mfrow = c(1, 2), mai = c(1.4, 0.5, 0.5, 0))
fataPlot <- with(fataData, barplot(FATALITIES, names.arg = EVENT, axisnames = FALSE, col = rgb(0,0,1,1/4)))
text(fataPlot, par("usr")[3], labels = fataData$EVENT, srt=60, adj = 1, xpd = TRUE, cex = 0.65)
injuPlot <- with(injuData, barplot(INJURIES, names.arg = EVENT, axisnames = FALSE, col = rgb(1,0,1,1/4)))
text(injuPlot, par("usr")[3], labels = injuData$EVENT, srt=60, adj = 1, xpd = TRUE, cex = 0.65)
title("Most Harmful Events", outer = TRUE, line = -1)
legend("topright", legend = c("Fatalities","Injuries"),
col = c(rgb(0,0,1,1/4), rgb(1,0,0,1/4)),
pch = 19, cex = 0.8)
For completeness, below it is shown the first 6 harmful events for fatalities.
head(fataData)
## EVENT FATALITIES
## 834 TORNADO 5633
## 130 EXCESSIVE HEAT 1903
## 153 FLASH FLOOD 978
## 275 HEAT 937
## 464 LIGHTNING 816
## 856 TSTM WIND 504
And for injuries.
head(injuData)
## EVENT INJURIES
## 834 TORNADO 91346
## 856 TSTM WIND 6957
## 170 FLOOD 6789
## 130 EXCESSIVE HEAT 6525
## 464 LIGHTNING 5230
## 275 HEAT 2100
In both cases, the TORNADO event has been the most harmful with respect to population health.
Concerning the damages we can plot just one graph. This because earlier we aggregated the data doing the sum of damages on properties and crops, as they have the same unit of measure ($).
par(mai = c(1.6, 1, 0.5, 0))
econDmgPlot <- with(econDmg, barplot(TOTDMG, names.arg = EVENT, axisnames = FALSE,
col = rgb(0,1,0,1/4), ylab = "Damage in $", font.lab = 2))
text(econDmgPlot, par("usr")[3], labels = econDmg$EVENT, srt=60, adj = 1, xpd = TRUE, cex = 0.65)
title("Total Damage (Properties and Crops)", outer = TRUE, line = -1)
For completeness, below it is shown the first 6 events that caused biggest damages.
head(econDmg)
## EVENT TOTDMG
## 170 FLOOD 150319678257
## 411 HURRICANE/TYPHOON 71913712800
## 834 TORNADO 57340614060
## 670 STORM SURGE 43323541000
## 244 HAIL 18752904943
## 153 FLASH FLOOD 17562129167
We can clearly see that the FLOOD event is the one that caused biggest dollars of damage.