Executive summary

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.

The goal of this analysis is to assess the impact of severe weather events on population health and assess the economic consequences.

Tornado is the harmful event with respect to population health, and Flood is the event which have the greatest economic consequences.

Data Processing

Data description

The data for this assignment come in the form of a comma-separated-value file compressed via the bzip2 algorithm to reduce its size. You can download the file from the course web site:

There is also some documentation of the database available. Here you will find how some of the variables are constructed/defined.

The events in the database start in the year 1950 and end in November 2011. In the earlier years of the database there are generally fewer events recorded, most likely due to a lack of good records. More recent years should be considered more complete.

Loading packages

The following R packages were used to support this analysis.

library(R.utils) # load bz2 file
library(data.table)
library(dplyr)
library(ggplot2)
library(tidyr)

Data preparation

url_data <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"

download.file(url_data,"repdata_data_StormData.csv.bz2")

# Unzip the downloaded file
if (!file.exists("repdata_data_StormData.csv")) 
    {bunzip2("repdata_data_StormData.csv.bz2","repdata_data_StormData.csv")}


storm <- data.table::fread("repdata_data_StormData.csv",header=TRUE)
str(storm)
## Classes 'data.table' and 'data.frame':   902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : chr  "4/18/1950 0:00:00" "4/18/1950 0:00:00" "2/20/1951 0:00:00" "6/8/1951 0:00:00" ...
##  $ BGN_TIME  : chr  "0130" "0145" "1600" "0900" ...
##  $ TIME_ZONE : chr  "CST" "CST" "CST" "CST" ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: chr  "MOBILE" "BALDWIN" "FAYETTE" "MADISON" ...
##  $ STATE     : chr  "AL" "AL" "AL" "AL" ...
##  $ EVTYPE    : chr  "TORNADO" "TORNADO" "TORNADO" "TORNADO" ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : chr  "" "" "" "" ...
##  $ BGN_LOCATI: chr  "" "" "" "" ...
##  $ END_DATE  : chr  "" "" "" "" ...
##  $ END_TIME  : chr  "" "" "" "" ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : chr  "" "" "" "" ...
##  $ END_LOCATI: chr  "" "" "" "" ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ 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  "" "" "" "" ...
##  $ WFO       : chr  "" "" "" "" ...
##  $ STATEOFFIC: chr  "" "" "" "" ...
##  $ ZONENAMES : chr  "" "" "" "" ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : chr  "" "" "" "" ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...
##  - attr(*, ".internal.selfref")=<externalptr>

There are 37 variables and 902297 observations in the database. However, for the purpose of this analysis, we subset 7 variables using dplyr package and lowercase their names.

storm2 <- storm %>% 
        select(c("EVTYPE","FATALITIES","INJURIES","PROPDMG","PROPDMGEXP","CROPDMG","CROPDMGEXP")) %>%
        rename_all(tolower)
head(storm2)
##     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

Based on the information above, the data table now has 902,297 observations and 7 variables. Below is a brief description of each variable :

  1. evtype : storm event type
  2. fatalities: amount of fatalities per event
  3. injuries : amount of injuries per event
  4. propdmg : property damage amount
  5. propdmgexp: property damage in exponents
  6. cropdmg : crop damage amount
  7. cropdmgexp: crop damage in exponents

To show the impact of weather events on the population health, the sum of both fatalities and injuries are computed by event type. Then, arrange it in descending order and we select the first 10 events types having the highest fatalities and injuries counts. The data were gather and turning it into categorical variables for creating a grouped bar plot.

health <-
        storm2 %>% select(evtype, fatalities, injuries) %>% 
        group_by(evtype) %>% 
        summarize(fatalities = sum(fatalities), injuries = sum(injuries), .groups='drop') %>%
        arrange(desc(fatalities), desc(injuries)) %>%
        slice(1:10) %>%
        gather(key = type, value = value, fatalities, injuries)

To calculate the economic damage the following variables were used:

PROPDMG and CROPDMG: Amount (without unit) of property damage and crop damage.

PROPDMGEXP and CROPDMGEXP: Unit expressed in power of 10 of the above variables (H,K,M B means Hundreds, Thousands, Millions and Billions respectively)

unique(storm2$propdmgexp)
##  [1] "K" "M" ""  "B" "m" "+" "0" "5" "6" "?" "4" "2" "3" "h" "7" "H" "-" "1" "8"
unique(storm2$cropdmgexp)
## [1] ""  "M" "K" "m" "B" "?" "0" "k" "2"
## first create an empty column
storm2$propdmgnum = 0

## fill in the data with correct units
storm2[storm2$propdmgexp %in% c("h","H"), ]$propdmgnum = storm2[storm2$propdmgexp %in% c("h","H"), ]$propdmg * 10^2

storm2[storm2$propdmgexp == "K", ]$propdmgnum = storm2[storm2$propdmgexp == "K", ]$propdmg * 10^3

storm2[storm2$propdmgexp %in% c("M","m"), ]$propdmgnum = storm2[storm2$propdmgexp %in% c("M","m"), ]$propdmg * 10^6

storm2[storm2$propdmgexp == "B", ]$propdmgnum = storm2[storm2$propdmgexp == "B", ]$propdmg * 10^9

# Convert H, K, M, B units to calculate Crop Damage

## create an empty column
storm2$cropdmgnum = 0

## assign correct values based on parameters
storm2[storm2$cropdmgexp == "H", ]$cropdmgnum = storm2[storm2$cropdmgexp == "H", ]$cropdmg * 10^2

storm2[storm2$cropdmgexp %in% c("k","K"), ]$cropdmgnum = storm2[storm2$cropdmgexp %in% c("K","k"), ]$cropdmg * 10^3

storm2[storm2$cropdmgexp %in% c("M","m"), ]$cropdmgnum = storm2[storm2$cropdmgexp %in% c("M","m"), ]$cropdmg * 10^6
storm2[storm2$cropdmgexp == "B", ]$cropdmgnum = storm2[storm2$cropdmgexp == "B", ]$cropdmg * 10^9

Aside from the manipulation to calculate cost, the methodology is pretty much the same for the rest of the manipulation to prepare the economic data

economic <-
        storm2 %>% select("evtype", "propdmgnum", "cropdmgnum") %>% 
        group_by(evtype) %>% 
        summarize(property = sum(propdmgnum), crop = sum(cropdmgnum), .groups='drop') %>%
        arrange(desc(property), desc(crop)) %>%
        slice(1:10) %>% 
        gather(key = type, value = value, property, crop)

Results

Across the United States, which types of events are most harmful with respect to population health?

The figure and table below show the amount of fatalities and injuries for the top 10 most harmful types of events. We can see that TORNADO is the most harmful with respect to population health.

health$evtype <- as.factor(health$evtype)

ggplot(data=health, aes(reorder(evtype, -value), value, fill=type)) +
        geom_bar(position = "dodge", stat="identity") + 
        labs(x="Event Type", y="Count") +
        #theme_bw() +
        theme(axis.text.x = element_text(angle = 20, vjust=0.7)) + 
        ggtitle("Total Number of Fatalities and Injuries of top 10 storm event types")+
        facet_wrap(vars(type),nrow=2,scales = "free_y")

health[order(health$type,health$value,decreasing=TRUE),]
## # A tibble: 20 × 3
##    evtype         type       value
##    <fct>          <chr>      <dbl>
##  1 TORNADO        injuries   91346
##  2 TSTM WIND      injuries    6957
##  3 FLOOD          injuries    6789
##  4 EXCESSIVE HEAT injuries    6525
##  5 LIGHTNING      injuries    5230
##  6 HEAT           injuries    2100
##  7 FLASH FLOOD    injuries    1777
##  8 HIGH WIND      injuries    1137
##  9 RIP CURRENT    injuries     232
## 10 AVALANCHE      injuries     170
## 11 TORNADO        fatalities  5633
## 12 EXCESSIVE HEAT fatalities  1903
## 13 FLASH FLOOD    fatalities   978
## 14 HEAT           fatalities   937
## 15 LIGHTNING      fatalities   816
## 16 TSTM WIND      fatalities   504
## 17 FLOOD          fatalities   470
## 18 RIP CURRENT    fatalities   368
## 19 HIGH WIND      fatalities   248
## 20 AVALANCHE      fatalities   224

Across the United States, which types of events have the greatest economic consequences?

The figure and table below show the total cost of property and crop damages caused by the the top 10 of types of events having greatest economic consequence. We can see that FLOOD is the event which have the greatest economic consequences.

economic$evtype <- as.factor(economic$evtype)

ggplot(data=economic, aes(reorder(evtype, -value), value, fill=type)) +
        geom_bar(position = "dodge", stat="identity") + 
        labs(x="Event Type", y="Damages ($)") +
        #theme_bw() +
        theme(axis.text.x = element_text(angle = 20, vjust=0.7)) + 
        ggtitle("Total cost of Proprety and Crop Damages by top 10 weather events")+
        facet_wrap(vars(type),nrow=2,scales = "free_y")

economic[order(economic$type,economic$value,decreasing=TRUE),]
## # A tibble: 20 × 3
##    evtype            type            value
##    <fct>             <chr>           <dbl>
##  1 FLOOD             property 144657709800
##  2 HURRICANE/TYPHOON property  69305840000
##  3 TORNADO           property  56937160480
##  4 STORM SURGE       property  43323536000
##  5 FLASH FLOOD       property  16140811510
##  6 HAIL              property  15732267220
##  7 HURRICANE         property  11868319010
##  8 TROPICAL STORM    property   7703890550
##  9 WINTER STORM      property   6688497250
## 10 HIGH WIND         property   5270046260
## 11 FLOOD             crop       5661968450
## 12 HAIL              crop       3025954450
## 13 HURRICANE         crop       2741910000
## 14 HURRICANE/TYPHOON crop       2607872800
## 15 FLASH FLOOD       crop       1421317100
## 16 TROPICAL STORM    crop        678346000
## 17 HIGH WIND         crop        638571300
## 18 TORNADO           crop        414953110
## 19 WINTER STORM      crop         26944000
## 20 STORM SURGE       crop             5000

Conclusion

This analysis shows by aggregating the data by storm events type that Tornado is the harmful event with respect to population health, and Flood is the event which have the greatest economic consequences.