knitr::opts_chunk$set(
echo = TRUE,
warning = FALSE,
message = FALSE,
fig.width = 9,
fig.height = 6
)
This analysis uses the NOAA Storm Database to identify the weather
event types that have caused the greatest harm to population health and
the greatest economic damage in the United States. The raw compressed
storm data are loaded directly into R and processed within this report.
Population-health impact is measured using the total number of
fatalities and injuries associated with each event type. Economic impact
is measured as the combined estimated property and crop damage after
converting the damage exponent fields into dollar multipliers. Event
names are standardized only by removing extra spaces and converting text
to uppercase so that the analysis remains close to the original
EVTYPE classifications. The results show which event types
should receive the greatest attention when considering historical human
and economic consequences.
The analysis begins directly from the original compressed NOAA file,
StormData.csv.bz2. If the file is not already in the
working directory, the code below downloads it from the course website.
R can read the bzip2-compressed CSV directly, so no preprocessing is
performed outside this document.
data_url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
data_file <- "StormData.csv.bz2"
if (!file.exists(data_file)) {
download.file(data_url, destfile = data_file, mode = "wb")
}
storm <- read.csv(
bzfile(data_file),
stringsAsFactors = FALSE
)
dim(storm)
## [1] 902297 37
Only the variables required for the two research questions are used. Event names are converted to uppercase and surrounding whitespace is removed. This transformation combines records that differ only in capitalization or accidental spacing without subjectively merging different event categories.
storm$EVTYPE_CLEAN <- toupper(trimws(storm$EVTYPE))
analysis_data <- storm[, c(
"EVTYPE_CLEAN",
"FATALITIES",
"INJURIES",
"PROPDMG",
"PROPDMGEXP",
"CROPDMG",
"CROPDMGEXP"
)]
head(analysis_data)
## EVTYPE_CLEAN 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
For population health, the total health impact for each event is defined as fatalities plus injuries. Fatalities and injuries are also retained separately so the final results can show both components.
analysis_data$HEALTH_IMPACT <-
analysis_data$FATALITIES + analysis_data$INJURIES
health_by_event <- aggregate(
cbind(FATALITIES, INJURIES, HEALTH_IMPACT) ~ EVTYPE_CLEAN,
data = analysis_data,
FUN = sum,
na.rm = TRUE
)
health_by_event <- health_by_event[
order(health_by_event$HEALTH_IMPACT, decreasing = TRUE),
]
top_health <- head(health_by_event, 10)
top_health
## EVTYPE_CLEAN FATALITIES INJURIES HEALTH_IMPACT
## 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
The economic variables require an additional transformation.
PROPDMG and CROPDMG contain the numeric damage
values, while PROPDMGEXP and CROPDMGEXP
contain magnitude indicators. The function below converts common
magnitude codes into numeric multipliers: H = hundreds,
K = thousands, M = millions, and
B = billions. Numeric exponent codes are interpreted as
powers of ten. Blank or unusual nonnumeric symbols are treated as a
multiplier of 1 so that the original numeric damage value is retained
rather than discarded.
exp_multiplier <- function(x) {
x <- toupper(trimws(as.character(x)))
mult <- rep(1, length(x))
mult[x == "H"] <- 1e2
mult[x == "K"] <- 1e3
mult[x == "M"] <- 1e6
mult[x == "B"] <- 1e9
numeric_code <- grepl("^[0-9]$", x)
mult[numeric_code] <- 10^as.numeric(x[numeric_code])
mult
}
analysis_data$PROP_MULT <- exp_multiplier(analysis_data$PROPDMGEXP)
analysis_data$CROP_MULT <- exp_multiplier(analysis_data$CROPDMGEXP)
analysis_data$PROPERTY_DAMAGE <-
analysis_data$PROPDMG * analysis_data$PROP_MULT
analysis_data$CROP_DAMAGE <-
analysis_data$CROPDMG * analysis_data$CROP_MULT
analysis_data$TOTAL_ECONOMIC_DAMAGE <-
analysis_data$PROPERTY_DAMAGE + analysis_data$CROP_DAMAGE
economic_by_event <- aggregate(
cbind(PROPERTY_DAMAGE, CROP_DAMAGE, TOTAL_ECONOMIC_DAMAGE) ~ EVTYPE_CLEAN,
data = analysis_data,
FUN = sum,
na.rm = TRUE
)
economic_by_event <- economic_by_event[
order(economic_by_event$TOTAL_ECONOMIC_DAMAGE, decreasing = TRUE),
]
top_economic <- head(economic_by_event, 10)
top_economic
## EVTYPE_CLEAN PROPERTY_DAMAGE CROP_DAMAGE TOTAL_ECONOMIC_DAMAGE
## 146 FLOOD 144657709807 5661968450 150319678257
## 364 HURRICANE/TYPHOON 69305840000 2607872800 71913712800
## 750 TORNADO 56947380677 414953270 57362333947
## 591 STORM SURGE 43323536000 5000 43323541000
## 204 HAIL 15735267513 3025954473 18761221986
## 130 FLASH FLOOD 16822723979 1421317100 18244041079
## 76 DROUGHT 1046106000 13972566000 15018672000
## 355 HURRICANE 11868319010 2741910000 14610229010
## 521 RIVER FLOOD 5118945500 5029459000 10148404500
## 379 ICE STORM 3944927860 5022113500 8967041360
The following table lists the ten event types with the largest combined number of fatalities and injuries.
top_health
## EVTYPE_CLEAN FATALITIES INJURIES HEALTH_IMPACT
## 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
The most harmful event type with respect to population health is TORNADO, with 96,979 combined fatalities and injuries. It accounts for 5,633 fatalities and 91,346 injuries in the dataset.
health_plot <- top_health[10:1, ]
par(mar = c(5, 11, 4, 2))
barplot(
health_plot$HEALTH_IMPACT,
names.arg = health_plot$EVTYPE_CLEAN,
horiz = TRUE,
las = 1,
xlab = "Total fatalities + injuries",
main = "Weather Events Most Harmful to Population Health"
)
Figure 1 shows that the health burden is highly concentrated among a relatively small number of event types. The leading event has a substantially larger combined health impact than most other categories in the top ten.
The next table lists the ten event types with the greatest combined property and crop damage.
top_economic_display <- top_economic
top_economic_display$PROPERTY_DAMAGE <-
top_economic_display$PROPERTY_DAMAGE / 1e9
top_economic_display$CROP_DAMAGE <-
top_economic_display$CROP_DAMAGE / 1e9
top_economic_display$TOTAL_ECONOMIC_DAMAGE <-
top_economic_display$TOTAL_ECONOMIC_DAMAGE / 1e9
names(top_economic_display)[2:4] <- c(
"PROPERTY_DAMAGE_BILLIONS",
"CROP_DAMAGE_BILLIONS",
"TOTAL_DAMAGE_BILLIONS"
)
top_economic_display
## EVTYPE_CLEAN PROPERTY_DAMAGE_BILLIONS CROP_DAMAGE_BILLIONS
## 146 FLOOD 144.657710 5.6619684
## 364 HURRICANE/TYPHOON 69.305840 2.6078728
## 750 TORNADO 56.947381 0.4149533
## 591 STORM SURGE 43.323536 0.0000050
## 204 HAIL 15.735268 3.0259545
## 130 FLASH FLOOD 16.822724 1.4213171
## 76 DROUGHT 1.046106 13.9725660
## 355 HURRICANE 11.868319 2.7419100
## 521 RIVER FLOOD 5.118945 5.0294590
## 379 ICE STORM 3.944928 5.0221135
## TOTAL_DAMAGE_BILLIONS
## 146 150.319678
## 364 71.913713
## 750 57.362334
## 591 43.323541
## 204 18.761222
## 130 18.244041
## 76 15.018672
## 355 14.610229
## 521 10.148404
## 379 8.967041
The event type with the greatest total economic consequences is FLOOD, with approximately $150.32 billion in combined property and crop damage.
economic_plot <- top_economic[10:1, ]
par(mar = c(5, 11, 4, 2))
barplot(
economic_plot$TOTAL_ECONOMIC_DAMAGE / 1e9,
names.arg = economic_plot$EVTYPE_CLEAN,
horiz = TRUE,
las = 1,
xlab = "Total economic damage (billions of U.S. dollars)",
main = "Weather Events With Greatest Economic Consequences"
)
Figure 2 demonstrates that a few event types account for a very large share of the estimated economic losses in the database. Property damage is responsible for much of the total economic impact among the highest-ranked event categories, although crop damage is also important for several types of severe weather.
Based on the NOAA Storm Database, TORNADO is the event type associated with the greatest historical harm to population health when fatalities and injuries are combined. FLOOD produces the greatest total estimated economic damage when property and crop losses are combined. These results answer the two required questions using the raw NOAA data and fully reproducible R code.