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 :
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).
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 :
Event types : in the data preparation, we ended up with 483 distinct entries or type events, which is slightly different from the permitted storm data events as described by the NOAA for the “preparers” who collected the data. We did not try to “clean” this up, because the level of sophistication required to do it far exceeds the extent of this specialization course.
Consequences on population health are aggregated in number of occurrences, but with respect to the data collection method, making the distinction between fatalities and injuries. This eventually leaves room for further interpretation of what one understands with the concept of ‘harmfulness’.
Economic damages are aggregated in billions of dollars, regardless of the type of economic damage (crops and/or property).
Time and location : we aggregate these metrics on a very general level, regardless of the time and location of the events.
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")
print(fatalities)
print(injuries)
print(damage)