library(ProjectTemplate)
setwd("..")
load.project()
## Loading project configuration
## Autoloading helper functions
## Running helper script: normalize-names.R
## Running helper script: trim.R
## Autoloading packages
## Loading package: ggplot2
## Loading package: stringr
## Loading package: lubridate
## Loading package: reshape2
## Autoloading data
## Loading cached data set: storms
## Loading required package: data.table
##
## Attaching package: 'data.table'
##
## The following objects are masked from 'package:lubridate':
##
## hour, mday, month, quarter, wday, week, yday, year
##
## Munging data
## Running preprocessing script: storms.R
## Warning: All formats failed to parse. No formats found.
## Warning: All formats failed to parse. No formats found.
## Warning: Adding new column 'storm.category' then assigning NULL (deleting it).
## Initializing logger
## Loading required package: log4r
##
## Attaching package: 'log4r'
##
## The following object is masked from 'package:base':
##
## debug
This analysis reviews the potential impact of severe weather events on human populations. Over 60 years of severe weather event data, collected by the National Oceanic and Atmospheric Administration (NOAA), is analyzed to ascertain the financial and health risks to human populations.
# standardize the variable names
original <- names(storms)
setnames(storms, normalize.names(original))
# data types
storms[, `:=`(bgn.date = mdy(substr(bgn.date, 1, str_locate(bgn.date, "\\s") -
1)), time.zone = as.factor(time.zone), evtype = as.factor(evtype), end.date = mdy(substr(end.date,
1, str_locate(end.date, "\\s") - 1)))]
## Warning: All formats failed to parse. No formats found.
## Warning: All formats failed to parse. No formats found.
# event types
storms[, `:=`(evtype, normalize.names(evtype))]
# categorize the event types into storm categories
storms[, `:=`(storm.category, NULL)]
storms[str_detect(evtype, "winter|snow|ice|freez|cold|blizzard|windchill|icy|sleet|frost|low.temp|wintry|hypothermia|record.low|heavy.mix"),
`:=`(storm.category, "Winter Storm")]
storms[str_detect(evtype, "tornado|wind|funnel|gustnado|torndao|duststorm|microburst|wnd|dust.devil|dust") &
is.na(storm.category), `:=`(storm.category, "Extreme Wind")]
storms[str_detect(evtype, "flood|rain|tide|fld|wet|flash.floooding|rapidly.rising.water|dam|high.water") &
is.na(storm.category), `:=`(storm.category, "Flooding")]
storms[str_detect(evtype, "drought|record.low.rainfall|dry|driest") & is.na(storm.category),
`:=`(storm.category, "Drought")]
storms[str_detect(evtype, "warm|heat|hot|record.high|high.temp") & is.na(storm.category),
`:=`(storm.category, "Heat")]
storms[str_detect(evtype, "erosion|slide|mud|erosin|avalance|landslump|avalanche") &
is.na(storm.category), `:=`(storm.category, "Erosion")]
storms[str_detect(evtype, "fire|smoke") & is.na(storm.category), `:=`(storm.category,
"Fire")]
storms[str_detect(evtype, "thunderstorm|hail|lightning|wall|tstm|lighting|precip|metro.storm|shower|cool|fog|mild") &
is.na(storm.category), `:=`(storm.category, "Summer Storm")]
storms[str_detect(evtype, "tsunami|coastal.surge|rogue.wave|seas|surf|swell|tropical.storm|hurricane|typhoon|spout|marine|current|coastal|drown|floyd|waves|surge") &
is.na(storm.category), `:=`(storm.category, "Coastal")]
storms[is.na(storm.category), `:=`(storm.category, "Other")]
Each of the severe weather events have been categorized into one of ten severe weather categories. These categories included the following.
Certain types of severe weather events either have occurred more frequently or have been reported more frequently than others. As can be seen from the associated plot Extreme Wind, Summer Storms, and Flooding are the most frequently reported severe weather events in the data.
freq <- storms[, .N, by = storm.category]
freq$storm.category <- with(freq, reorder(storm.category, N))
ggplot(freq, aes(storm.category, N, fill = storm.category)) + geom_bar(stat = "identity") +
coord_flip() + ggtitle("Types of Severe Weather Events") + ylab("Number of Events") +
xlab("") + theme(legend.position = "none")
The impact of severe weather events on human health is a major source of concern. The number of human fatalities and the number of human injuries were used to ascertain the impact to human health of severe weather events.
It should be noted that different types of events pose different risks to human health and may require different types of preparation. The preparation for large numbers of fatalities may differ from the preparation for injuries. This this
# human impacts by storm category
impacts <- storms[, list(injuries = sum(injuries, na.rm = TRUE), fatalities = sum(fatalities,
na.rm = TRUE), total = sum(injuries, na.rm = TRUE) + sum(fatalities, na.rm = TRUE)),
by = storm.category]
# exclude categories with low impact
impacts <- impacts[total > 1000]
impacts$storm.category <- with(impacts, reorder(storm.category, total))
ggplot(impacts, aes(storm.category, total, fill = storm.category)) + geom_bar(stat = "identity") +
coord_flip() + # scale_x_sqrt () + scale_y_sqrt () +
ggtitle("Health Impact of Severe Weather") + xlab("") + ylab("Number of Human Fatalities/Injuries") +
theme(legend.position = "none")
Extreme winds pose the greatest risk to human health. Events such as tornados, wind storms, and microbursts have caused the highest numbers of both injuries and fatalities. This category far exceeds any other.
Another source of concern for severe weather events is the economic and financial impact. The data provides a way to characterize the financial impact by measuring the amount of property damage and crop damage.
# human impacts by storm category
impacts <- storms[, list(total = sum(cropdmg, na.rm = TRUE) + sum(propdmg, na.rm = TRUE)),
by = storm.category]
impacts$storm.category <- with(impacts, reorder(storm.category, total))
ggplot(impacts, aes(storm.category, total, fill = storm.category)) + geom_bar(stat = "identity") +
coord_flip() + ggtitle("Economic Impact of Severe Weather") + xlab("") +
ylab("Financial Impact (US Dollar)") + theme(legend.position = "none")
Extreme winds again pose the greatest outsized financial risk. Following this Flooding causes the next highest financial risk.