Synopsis

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.

Two observations are found:

  1. Across the United States, events in Typhoon (as indicated in the EVTYPE) is most harmful with respect to population health
  2. Across the United States, flood events have the greatest economic consequences.

Section 1 on Data Processing - Load and Cleaning

First, we download the data and filter down to only the columns needed with some data transformation.

knitr::opts_chunk$set(echo = TRUE,warning = FALSE, message = FALSE, cache= TRUE)
##Loading libraries and preprocessing the data
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ lubridate 1.9.4     ✔ tibble    3.3.0
## ✔ purrr     1.2.0     ✔ tidyr     1.3.1
## ✔ readr     2.1.6
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#Download the file
url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(url,destfile="NOAA.bz2", method="curl")
stormdata <- read.csv("NOAA.bz2")

#Check dimensions, names and first few lines
dim(stormdata)
## [1] 902297     37
names(stormdata)
##  [1] "STATE__"    "BGN_DATE"   "BGN_TIME"   "TIME_ZONE"  "COUNTY"    
##  [6] "COUNTYNAME" "STATE"      "EVTYPE"     "BGN_RANGE"  "BGN_AZI"   
## [11] "BGN_LOCATI" "END_DATE"   "END_TIME"   "COUNTY_END" "COUNTYENDN"
## [16] "END_RANGE"  "END_AZI"    "END_LOCATI" "LENGTH"     "WIDTH"     
## [21] "F"          "MAG"        "FATALITIES" "INJURIES"   "PROPDMG"   
## [26] "PROPDMGEXP" "CROPDMG"    "CROPDMGEXP" "WFO"        "STATEOFFIC"
## [31] "ZONENAMES"  "LATITUDE"   "LONGITUDE"  "LATITUDE_E" "LONGITUDE_"
## [36] "REMARKS"    "REFNUM"
head(stormdata)
##   STATE__           BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE  EVTYPE
## 1       1  4/18/1950 0:00:00     0130       CST     97     MOBILE    AL TORNADO
## 2       1  4/18/1950 0:00:00     0145       CST      3    BALDWIN    AL TORNADO
## 3       1  2/20/1951 0:00:00     1600       CST     57    FAYETTE    AL TORNADO
## 4       1   6/8/1951 0:00:00     0900       CST     89    MADISON    AL TORNADO
## 5       1 11/15/1951 0:00:00     1500       CST     43    CULLMAN    AL TORNADO
## 6       1 11/15/1951 0:00:00     2000       CST     77 LAUDERDALE    AL TORNADO
##   BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END COUNTYENDN
## 1         0                                               0         NA
## 2         0                                               0         NA
## 3         0                                               0         NA
## 4         0                                               0         NA
## 5         0                                               0         NA
## 6         0                                               0         NA
##   END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES INJURIES PROPDMG
## 1         0                      14.0   100 3   0          0       15    25.0
## 2         0                       2.0   150 2   0          0        0     2.5
## 3         0                       0.1   123 2   0          0        2    25.0
## 4         0                       0.0   100 2   0          0        2     2.5
## 5         0                       0.0   150 2   0          0        2     2.5
## 6         0                       1.5   177 2   0          0        6     2.5
##   PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES LATITUDE LONGITUDE
## 1          K       0                                         3040      8812
## 2          K       0                                         3042      8755
## 3          K       0                                         3340      8742
## 4          K       0                                         3458      8626
## 5          K       0                                         3412      8642
## 6          K       0                                         3450      8748
##   LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1       3051       8806              1
## 2          0          0              2
## 3          0          0              3
## 4          0          0              4
## 5          0          0              5
## 6          0          0              6
#Subset of relevant data and convert exponents to uppercase
datasubset <- stormdata %>% select(EVTYPE,FATALITIES,INJURIES,PROPDMG,PROPDMGEXP,CROPDMG,CROPDMGEXP) %>% mutate (
        PROPDMGEXP = toupper(PROPDMGEXP),
        CROPDMGEXP = toupper(CROPDMGEXP),
# Directly calculate the multiplier using case_match
    prop_val = case_match(PROPDMGEXP,
      "H" ~ 100,
      "K" ~ 1000,
      "M" ~ 1000000,
      "B" ~ 1000000000,
      .default = 1
    ),
    crop_val = case_match(CROPDMGEXP,
      "H" ~ 100,
      "K" ~ 1000,
      "M" ~ 1000000,
      "B" ~ 1000000000,
      .default = 1
    ),
    
    # Final Economic Calculation
    TOTAL_ECON = (PROPDMG * prop_val) + (CROPDMG * crop_val),
    TOTAL_HEALTH = FATALITIES + INJURIES
)

Section 2 - Results

#2A. Qn1) Impact on Population Health For Question 1, we sum fatalities and injuries to see which weather events are the most dangerous.Based on the chart below, it appears that tornado has the highest impact on population health.

datasubset %>%
  group_by(EVTYPE) %>%
  summarise(total = sum(TOTAL_HEALTH)) %>%
  slice_max(total, n = 10) %>% #slice to get the top 10 categories
  ggplot(aes(x = reorder(EVTYPE, total), y = total)) +
  geom_col(fill = "darkred") +
  coord_flip() +
  labs(title = "Highest Health Impact", x = "", y = "Fatalities and Injuries")

#2B. Q2) Impact On Economy and Actual Damage Costs For Question 2, we sum the property and crop damage to find the most “expensive” events.Based on the chart below, it appears that flood has the highest economic impact.

datasubset %>%
  group_by(EVTYPE) %>%
  summarise(total = sum(TOTAL_ECON)) %>%
  slice_max(total, n = 10) %>% #slice to get the top 10 categories
  ggplot(aes(x = reorder(EVTYPE, total), y = total)) +
  geom_col(fill = "steelblue") +
  coord_flip() +
  labs(title = "Highest Economic Impact", x = "", y = "Costs of Damage in USD")