This analysis uses the NOAA Storm Database to find which types of severe weather events have had the biggest impact on people and on the economy in the United States. For population health, the analysis uses the total number of fatalities and injuries for each type of event. For economic impact, property and crop damage are combined after converting the damage codes into dollar values. The analysis starts directly from the original compressed NOAA data file. The results show that tornadoes have the largest impact on population health, while floods have caused the highest economic losses.
The original NOAA Storm Database is loaded directly from the compressed CSV file provided for the assignment.
storm <- read.csv(
"repdata_data_StormData.csv.bz2",
stringsAsFactors = FALSE
)
dim(storm)
## [1] 902297 37
The ggplot2 package is used later to create the
graphs.
library(ggplot2)
The main variables needed for this analysis are the event type, fatalities, injuries, property damage, and crop damage. First, these variables are checked to see how they are stored in the dataset.
str(storm[, c(
"EVTYPE",
"FATALITIES",
"INJURIES",
"PROPDMG",
"PROPDMGEXP",
"CROPDMG",
"CROPDMGEXP"
)])
## 'data.frame': 902297 obs. of 7 variables:
## $ EVTYPE : chr "TORNADO" "TORNADO" "TORNADO" "TORNADO" ...
## $ FATALITIES: num 0 0 0 0 0 0 0 0 1 0 ...
## $ INJURIES : num 15 0 2 2 2 6 1 0 14 0 ...
## $ PROPDMG : num 25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
## $ PROPDMGEXP: chr "K" "K" "K" "K" ...
## $ CROPDMG : num 0 0 0 0 0 0 0 0 0 0 ...
## $ CROPDMGEXP: chr "" "" "" "" ...
The event types are also checked because some of them are written in slightly different ways in the original dataset.
length(unique(storm$EVTYPE))
## [1] 985
head(sort(unique(storm$EVTYPE)), 30)
## [1] " HIGH SURF ADVISORY" " COASTAL FLOOD"
## [3] " FLASH FLOOD" " LIGHTNING"
## [5] " TSTM WIND" " TSTM WIND (G45)"
## [7] " WATERSPOUT" " WIND"
## [9] "?" "ABNORMAL WARMTH"
## [11] "ABNORMALLY DRY" "ABNORMALLY WET"
## [13] "ACCUMULATED SNOWFALL" "AGRICULTURAL FREEZE"
## [15] "APACHE COUNTY" "ASTRONOMICAL HIGH TIDE"
## [17] "ASTRONOMICAL LOW TIDE" "AVALANCE"
## [19] "AVALANCHE" "BEACH EROSIN"
## [21] "Beach Erosion" "BEACH EROSION"
## [23] "BEACH EROSION/COASTAL FLOOD" "BEACH FLOOD"
## [25] "BELOW NORMAL PRECIPITATION" "BITTER WIND CHILL"
## [27] "BITTER WIND CHILL TEMPERATURES" "Black Ice"
## [29] "BLACK ICE" "BLIZZARD"
To make the event names a little more consistent, they are converted to uppercase and extra spaces at the beginning or end are removed. The event categories are otherwise kept as they appear in the original data.
storm$EVTYPE <- toupper(trimws(storm$EVTYPE))
For this analysis, health impact is measured by adding fatalities and injuries for each record.
storm$HEALTH_IMPACT <- storm$FATALITIES + storm$INJURIES
health <- aggregate(
HEALTH_IMPACT ~ EVTYPE,
data = storm,
FUN = sum,
na.rm = TRUE
)
health <- health[
order(health$HEALTH_IMPACT, decreasing = TRUE),
]
health_top10 <- head(health, 10)
health_top10
## EVTYPE HEALTH_IMPACT
## 750 TORNADO 96979
## 108 EXCESSIVE HEAT 8428
## 771 TSTM WIND 7461
## 146 FLOOD 7259
## 410 LIGHTNING 6046
## 235 HEAT 3037
## 130 FLASH FLOOD 2755
## 379 ICE STORM 2064
## 677 THUNDERSTORM WIND 1621
## 880 WINTER STORM 1527
The event types are then ordered from the highest to the lowest total health impact, and the top ten are used in the results.
Property and crop damage values use an additional code to show their
scale. For example, K means thousands, M means
millions, and B means billions. Some values also appear in
lowercase, so they are converted to uppercase before being
processed.
Numeric codes are treated as powers of ten. Codes that cannot be interpreted are given a multiplier of zero.
damage_multiplier <- function(x) {
x <- toupper(trimws(as.character(x)))
multiplier <- rep(0, length(x))
multiplier[x == "H"] <- 1e2
multiplier[x == "K"] <- 1e3
multiplier[x == "M"] <- 1e6
multiplier[x == "B"] <- 1e9
numeric_codes <- x %in% as.character(0:9)
multiplier[numeric_codes] <- 10^as.numeric(x[numeric_codes])
multiplier
}
The property and crop damage values are converted into dollar amounts. They are then added together to create one total economic damage value for each record.
storm$PROPERTY_DAMAGE <- storm$PROPDMG *
damage_multiplier(storm$PROPDMGEXP)
storm$CROP_DAMAGE <- storm$CROPDMG *
damage_multiplier(storm$CROPDMGEXP)
storm$ECONOMIC_DAMAGE <- storm$PROPERTY_DAMAGE +
storm$CROP_DAMAGE
The total economic damage is grouped by event type and ordered from highest to lowest.
economic <- aggregate(
ECONOMIC_DAMAGE ~ EVTYPE,
data = storm,
FUN = sum,
na.rm = TRUE
)
economic <- economic[
order(economic$ECONOMIC_DAMAGE, decreasing = TRUE),
]
economic_top10 <- head(economic, 10)
economic_top10
## EVTYPE ECONOMIC_DAMAGE
## 146 FLOOD 150319678250
## 364 HURRICANE/TYPHOON 71913712800
## 750 TORNADO 57362333884
## 591 STORM SURGE 43323541000
## 204 HAIL 18761221926
## 130 FLASH FLOOD 18244040872
## 76 DROUGHT 15018672000
## 355 HURRICANE 14610229010
## 521 RIVER FLOOD 10148404500
## 379 ICE STORM 8967041360
The results show clear differences between weather event types. The following graph shows the ten events with the highest combined number of fatalities and injuries.
ggplot(
health_top10,
aes(
x = reorder(EVTYPE, HEALTH_IMPACT),
y = HEALTH_IMPACT
)
) +
geom_col() +
coord_flip() +
labs(
title = "Weather Events with the Greatest Population Health Impact",
x = "Event Type",
y = "Total Fatalities and Injuries"
) +
theme_minimal()
Figure 1. The ten weather event types with the highest combined number of fatalities and injuries.
Tornadoes have the largest health impact by a wide margin, with
96,979 combined fatalities and injuries. Excessive heat is second with
8,428, followed by TSTM WIND with 7,461, floods with 7,259,
and lightning with 6,046. Based on these results, tornadoes clearly
stand out as the event type with the greatest recorded impact on
population health.
The next graph shows the ten event types with the highest combined property and crop damage.
ggplot(
economic_top10,
aes(
x = reorder(EVTYPE, ECONOMIC_DAMAGE),
y = ECONOMIC_DAMAGE / 1e9
)
) +
geom_col() +
coord_flip() +
labs(
title = "Weather Events with the Greatest Economic Impact",
x = "Event Type",
y = "Total Economic Damage (Billions of US Dollars)"
) +
theme_minimal()
Figure 2. The ten weather event types with the highest combined property and crop damage. Values are shown in billions of U.S. dollars.
Floods caused the highest economic losses, with about $150.3 billion in total property and crop damage. Hurricane/typhoon events are second with about $71.9 billion, followed by tornadoes with $57.4 billion and storm surges with $43.3 billion. From these results, floods are the event type with the greatest recorded economic impact.
One limitation of this analysis is that the NOAA dataset contains
different names for events that may be very similar, such as
TSTM WIND and THUNDERSTORM WIND. To keep the
processing simple and avoid manually changing the original categories,
the analysis only standardizes capitalization and removes extra
spaces.