Synopsis

According to the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database, we assess wich types of extreme weather events were the most harmful in the USA over the years 1950-2011. We established a ranking of fatalities, injuries and economic damage by event type, and here are the 2 key findings :

  1. In terms of population health, tornadoes have the greatest impact both on fatalities (tornadoes account for 5 633 deaths, while excessive heat “only” for 1903 deaths) and injuries (tornadoes account for 91 346 injuries, while TSTM wind “only” accounts for 6 957 injuries).

  2. In terms of economic damage, floods caused the largest impact (accounting for 150.3 billion dollars of damage, whereas hurricane/typhoon account for 71.9 billion dollars).

In this analysis, 4 considerations are taken into account :

Data processing

knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
library(R.utils)
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.1 (2020-08-26 16:20:06 UTC) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.24.0 (2020-08-26 16:11:58 UTC) successfully loaded. See ?R.oo for help.
## 
## Attaching package: 'R.oo'
## The following object is masked from 'package:R.methodsS3':
## 
##     throw
## The following objects are masked from 'package:methods':
## 
##     getClasses, getMethods
## The following objects are masked from 'package:base':
## 
##     attach, detach, load, save
## R.utils v2.10.1 (2020-08-26 22:50:31 UTC) successfully loaded. See ?R.utils for help.
## 
## Attaching package: 'R.utils'
## The following object is masked from 'package:utils':
## 
##     timestamp
## The following objects are masked from 'package:base':
## 
##     cat, commandArgs, getOption, inherits, isOpen, nullfile, parse,
##     warnings
library(data.table)
library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.1     ✓ purrr   0.3.4
## ✓ tibble  3.0.1     ✓ dplyr   1.0.0
## ✓ tidyr   1.1.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## ── Conflicts ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::between()   masks data.table::between()
## x tidyr::extract()   masks R.utils::extract()
## x dplyr::filter()    masks stats::filter()
## x dplyr::first()     masks data.table::first()
## x dplyr::lag()       masks stats::lag()
## x dplyr::last()      masks data.table::last()
## x purrr::transpose() masks data.table::transpose()
library(ggplot2)
library(knitr)
## Download the data

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

if (!file.exists("StormData.csv.bz2")) {
    download.file(url, "StormData.csv.bz2")
}

data <- fread("StormData.csv.bz2")
## Variable selection from the original dataset

# In order to answer to the 2 questions of the assignment, we went through the available documentation on the National Weather Service website 
# (https://d396qusza40orc.cloudfront.net/repdata%2Fpeer2_doc%2Fpd01016005curr.pdf) and selected the relevant variables : 
#
# - Storm event types = EVTYPE
#
# - Consequences on the population health = FATALITIES, INJURIES
#
# - Economic consequences = PROPDMG,PROPDMGEXP,CROPDMG,CROPDMGEXP

prep <- data %>% select(
  EVTYPE,FATALITIES,INJURIES,PROPDMG,PROPDMGEXP,CROPDMG,CROPDMGEXP
  )
# First convert damages into billions with property damages
prep <- prep %>%
  mutate(PROPDMG = case_when(
    PROPDMGEXP == "K" ~ PROPDMG / 1000000,
    PROPDMGEXP == "M" ~ PROPDMG / 1000,
    PROPDMGEXP == "B" ~ PROPDMG,
    TRUE ~ 0
  )) %>%

# Then with crop damages
  mutate(CROPDMG = case_when(
    CROPDMGEXP == "K" ~ CROPDMG / 1000000,
    CROPDMGEXP == "M" ~ CROPDMG / 1000,
    CROPDMGEXP == "B" ~ CROPDMG,
    TRUE ~ 0
  )) %>%

# Now aggregation of all types of damages
mutate(DMG = PROPDMG + CROPDMG) %>%
  
# Now aggregation by type of event
  select(EVTYPE,FATALITIES,INJURIES,DMG) %>%
  group_by(EVTYPE) %>%
  summarise(
    FATALITIES = sum(FATALITIES, na.rm = TRUE),
    INJURIES = sum(INJURIES, na.rm = TRUE),
    DMG = sum(DMG, na.rm = TRUE)
  )

saveRDS(prep, "prep.rds")
## Data viz

fat <- readRDS("prep.rds") %>% 
  arrange(desc(FATALITIES)) %>%
  head(10)

fatalities <- ggplot(fat,aes(x=fct_reorder(EVTYPE, FATALITIES),y=FATALITIES)) + geom_col() + coord_flip() + 
  labs (title= "Fatalities : 10 most harmful types of weather events in the USA", 
        caption = "Source : U.S. National Oceanic and Atmospheric Administration's (NOAA) storm database, 1950-2011",
        x = "Event type",
        y = "Nb of fatalities")

injuries <- ggplot(fat,aes(x=fct_reorder(EVTYPE, INJURIES),y=INJURIES)) + geom_col() + coord_flip() + 
  labs (title= "Injuries : 10 most harmful types of weather events in the USA", 
        caption = "Source : U.S. National Oceanic and Atmospheric Administration's (NOAA) storm database, 1950-2011",
        x = "Event type",
        y = "Nb of injuries")

damage <- ggplot(fat,aes(x=fct_reorder(EVTYPE, DMG),y=DMG)) + geom_col() + coord_flip() + 
  labs (title= "Economic damage : 10 most harmful types of weather events in the USA", 
        caption = "Source : U.S. National Oceanic and Atmospheric Administration's (NOAA) storm database, 1950-2011",
        x = "Event type",
        y = "Economic damage in $ billions")

Results

print(fatalities)

print(injuries)

print(damage)