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. The U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database tracks characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of fatalities, injuries, and property damage.
The data is downloaded using a URL link provided by the website. The downloaded file is stored in a temporary file and read as a .csv into the data variable directly from its .bz2 archive.
# load packages
source('packages.R')
## Loading required package: pacman
## Warning: package 'pacman' was built under R version 3.2.4
# store URL and initiate a temporary file
URL <- 'https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2'
temp <- tempfile()
download.file(URL, temp)
# read data from .bz2 as .csv
data <- read.csv(temp)
unlink(temp)
Question 1. Across the United States, which types of events (as indicated in the 𝙴𝚅𝚃𝚈𝙿𝙴 variable) are most harmful with respect to population health?
The variables which can be used to quantify population health are FATALITIES and INJURIES.
par(mfrow = c(1,2))
# Sums of injuries for each event type
injs <- aggregate(INJURIES ~ EVTYPE, data, sum)
# Sums of top 10 event types with the most injuries
injs <- head(injs[order(injs$INJURIES, decreasing = TRUE),], 10)
injs$HARM <- factor(rep(names(injs)[2], nrow(injs)))
names(injs)[2] <- 'value'
barplot(height = injs$value, names.arg = injs$EVTYPE, las = 2,
main = 'Injuries')
# Sums of fatalities for each event type
fats <- aggregate(FATALITIES ~ EVTYPE, data, sum)
# Sums of top 10 event types with the most fatalities
fats <- head(fats[order(fats$FATALITIES, decreasing = TRUE),], 10)
fats$HARM <- factor(rep(names(fats)[2], nrow(fats)))
names(fats)[2] <- 'value'
barplot(height = fats$value, names.arg = injs$EVTYPE, las = 2,
main = 'Fatalities')
These barplots summarize the total amounts of injuries and fatalities per weather event. Each plot contains 10 events with the highest number of events affecting population health. Tornados appear to cause the highest amount of injuries and fatalities among all weather events.
Question 2. Across the United States, which types of events have the greatest economic consequences?
par(mfrow = c(1,2))
# Sums of property damage for each event type
props <- aggregate(PROPDMG ~ EVTYPE, data, sum)
# Sums of top 10 event types with the most property damage
props <- head(props[order(props$PROPDMG, decreasing = TRUE),], 10)
barplot(height = props$PROPDMG, names.arg = props$EVTYPE, las = 2,
main = 'Property damage')
In this barplot we summarize the 10 weather events which cause highest property damage. Tornadoes are once again prominent.
# Sums of crop damage for each event type
crops <- aggregate(CROPDMG ~ EVTYPE, data, sum)
# Sums of top 10 event types with the most crop damage
head(crops[order(crops$CROPDMG, decreasing = TRUE),], 10)
## EVTYPE CROPDMG
## 244 HAIL 579596.28
## 153 FLASH FLOOD 179200.46
## 170 FLOOD 168037.88
## 856 TSTM WIND 109202.60
## 834 TORNADO 100018.52
## 760 THUNDERSTORM WIND 66791.45
## 95 DROUGHT 33898.62
## 786 THUNDERSTORM WINDS 18684.93
## 359 HIGH WIND 17283.21
## 290 HEAVY RAIN 11122.80
This table ranks weather events by the amount of crop damage.