This analysis uses the NOAA Storm Database (1950-2011) to find which weather events are most harmful across the United States. Fatalities and injuries were used to measure harm to population health. Property and crop damage were converted to dollars and added together to measure economic consequences. Tornadoes caused the most harm to population health. Floods caused the greatest economic damage, followed by hurricanes/typhoons and tornadoes. Results are shown in two figures.
The raw data is downloaded from the course website and read directly from the compressed file.
url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
if (!file.exists("StormData.csv.bz2")) download.file(url, "StormData.csv.bz2", mode = "wb")
storm <- read.csv("StormData.csv.bz2", stringsAsFactors = FALSE)
dim(storm)
## [1] 902297 37
The event type names are inconsistent in capitalisation and spacing, so they are converted to upper case and trimmed so that the same event is counted together.
storm$EVTYPE <- toupper(trimws(storm$EVTYPE))
To measure harm to population health, fatalities and injuries are added up for each event type and combined into a total.
health <- aggregate(cbind(FATALITIES, INJURIES) ~ EVTYPE, data = storm, FUN = sum)
health$TOTAL <- health$FATALITIES + health$INJURIES
health <- health[order(-health$TOTAL), ]
head(health, 10)
## EVTYPE FATALITIES INJURIES TOTAL
## 750 TORNADO 5633 91346 96979
## 108 EXCESSIVE HEAT 1903 6525 8428
## 771 TSTM WIND 504 6957 7461
## 146 FLOOD 470 6789 7259
## 410 LIGHTNING 816 5230 6046
## 235 HEAT 937 2100 3037
## 130 FLASH FLOOD 978 1777 2755
## 379 ICE STORM 89 1975 2064
## 677 THUNDERSTORM WIND 133 1488 1621
## 880 WINTER STORM 206 1321 1527
Figure 1 shows the ten event types with the highest combined number of fatalities and injuries.
top_health <- head(health, 10)
par(mar = c(5, 11, 2, 1))
barplot(rev(top_health$TOTAL), names.arg = rev(top_health$EVTYPE),
horiz = TRUE, las = 1, col = "steelblue",
xlab = "Total fatalities + injuries")
Figure 1: The ten event types with the most fatalities plus injuries in the U.S., 1950-2011. Tornadoes are by far the most harmful to population health.
Property and crop damage are stored as a number and a letter that gives its size (H = hundreds, K = thousands, M = millions, B = billions). The letter is converted to a multiplier so that damage can be compared in dollars. Entries with any other symbol are treated as a multiplier of 1, because the documentation only defines H, K, M and B.
multiplier <- function(x) {
x <- toupper(x)
ifelse(x == "H", 1e2,
ifelse(x == "K", 1e3,
ifelse(x == "M", 1e6,
ifelse(x == "B", 1e9, 1))))
}
storm$PROPLOSS <- storm$PROPDMG * multiplier(storm$PROPDMGEXP)
storm$CROPLOSS <- storm$CROPDMG * multiplier(storm$CROPDMGEXP)
econ <- aggregate(cbind(PROPLOSS, CROPLOSS) ~ EVTYPE, data = storm, FUN = sum)
econ$TOTAL <- (econ$PROPLOSS + econ$CROPLOSS) / 1e9
econ <- econ[order(-econ$TOTAL), ]
head(econ, 10)
## EVTYPE PROPLOSS CROPLOSS TOTAL
## 146 FLOOD 144657709807 5661968450 150.319678
## 364 HURRICANE/TYPHOON 69305840000 2607872800 71.913713
## 750 TORNADO 56937160779 414953270 57.352114
## 591 STORM SURGE 43323536000 5000 43.323541
## 204 HAIL 15732267543 3025954473 18.758222
## 130 FLASH FLOOD 16140862067 1421317100 17.562179
## 76 DROUGHT 1046106000 13972566000 15.018672
## 355 HURRICANE 11868319010 2741910000 14.610229
## 521 RIVER FLOOD 5118945500 5029459000 10.148404
## 379 ICE STORM 3944927860 5022113500 8.967041
Figure 2 shows the ten event types with the greatest total property and crop damage.
top_econ <- head(econ, 10)
par(mar = c(5, 11, 2, 1))
barplot(rev(top_econ$TOTAL), names.arg = rev(top_econ$EVTYPE),
horiz = TRUE, las = 1, col = "darkorange",
xlab = "Total property + crop damage (billions of dollars)")
Figure 2: The ten event types with the greatest total property and crop damage in the U.S., 1950-2011, in billions of dollars. Floods cause the most economic damage.
Economic consequences: Floods caused the greatest total economic damage, about 150 billion dollars in property and crop damage combined. Hurricanes/typhoons (72 billion) and tornadoes (57 billion) came next. Hurricane damage is split across two event names, HURRICANE/TYPHOON and HURRICANE, so the true hurricane total is even higher.