knitr::opts_chunk$set(message = FALSE, warning = FALSE)

Storm Data between 1996 and 2011

Synopsis

Exploring U.S National Oceanic and Atmospheric Administration’s (NOAA) storm database from 1996 to 2011 for storm events that cause most fatalities and those that cause economic damage.

Downloading and loadingthe data

Downloading the data from the url copied from the project page.

url <- paste0("https://d396qusza40orc.cloudfront.net/",
        "repdata%2Fdata%2FStormData.csv.bz2")
download.file(url, destfile = "strmData.csv.bz2")

Reading the Data

storm_data <- read.csv("strmData.csv.bz2")

Results

Data Processing

After filtering the data set for variables BGN_DATE and END_DATE not being empty strings, BGN_DATE and END_DATE are converted from character type to Date type. A new variable called year has been created which contains only the year from the BGN_DATE. The data set is grouped by year and the number of observations for each year counted and plotted.
By observing the plot we see that data since the year 1996 to 2011 has been very extensive, hence considering the data between these years as complete and carrying out the data exploration.

library(tidyverse)
# changing BGN_DATE, END_DATE to Date format and creating new variable year
storm_data <- storm_data %>% filter(BGN_DATE != "", END_DATE != "") %>%
  mutate(BGN_DATE = as.Date(BGN_DATE, "%m/%d/%Y"),
    END_DATE = as.Date(END_DATE, "%m/%d/%Y"),
         year = format(BGN_DATE, "%Y"))

# grouping by year and plotting the number of observations for each year to
# decide the start and end years to carry out the exploration
storm_data %>%
  group_by(year) %>%
  summarize(n_observations = n()) %>%
  ggplot(aes(year, n_observations)) +
  geom_col()

# limiting the data to years between 1996 and 2011, both inclusive
storm_data <- storm_data %>%
  filter(between(year, "1996", "2011"))

Exploring the event types in the database and the events in which fatalities occurred. There are 516 different or unique storm event types and among these 516 event types, fatalities have occurred during 109 storm events types.

length(unique(storm_data$EVTYPE))
## [1] 516
# 20 storm event that caused most human fatalities
fatality_20_events <- storm_data %>%
  filter(FATALITIES > 0) %>%
  arrange(desc(FATALITIES)) %>%
  .$EVTYPE %>%
  unique() %>%
  head(n = 20)
fatality_20_events
##  [1] "TORNADO"                 "EXCESSIVE HEAT"         
##  [3] "TSUNAMI"                 "TROPICAL STORM"         
##  [5] "FLASH FLOOD"             "HEAVY RAIN"             
##  [7] "HEAT"                    "HURRICANE/TYPHOON"      
##  [9] "COLD AND SNOW"           "WILDFIRE"               
## [11] "LANDSLIDE"               "HURRICANE"              
## [13] "FLOOD"                   "FOG"                    
## [15] "STORM SURGE/TIDE"        "EXTREME COLD/WIND CHILL"
## [17] "HEAVY SNOW"              "HIGH WIND"              
## [19] "BLIZZARD"                "THUNDERSTORM WIND"
# 20 most frequently occurring storm events, causing fatalities
most_frequent_events <- storm_data %>%
  filter(FATALITIES > 0) %>%
  count(EVTYPE) %>%
  arrange(desc(n)) %>%
  head(n = 20) %>%
  .$EVTYPE
most_frequent_events
##  [1] "LIGHTNING"               "FLASH FLOOD"            
##  [3] "EXCESSIVE HEAT"          "TORNADO"                
##  [5] "RIP CURRENT"             "FLOOD"                  
##  [7] "TSTM WIND"               "RIP CURRENTS"           
##  [9] "HIGH WIND"               "AVALANCHE"              
## [11] "HEAT"                    "WINTER STORM"           
## [13] "THUNDERSTORM WIND"       "STRONG WIND"            
## [15] "EXTREME COLD/WIND CHILL" "EXTREME COLD"           
## [17] "HEAVY SNOW"              "COLD/WIND CHILL"        
## [19] "HIGH SURF"               "HEAVY RAIN"
# the most frequent storm events and also causing most fatalities
frequent_fatal_events <- intersect(fatality_20_events, most_frequent_events)

# plotting the data for storm events that have occurred more frequently and
# have caused most fatalities
storm_data %>%
  filter(EVTYPE %in% frequent_fatal_events, FATALITIES > 0) %>%
  group_by(year, EVTYPE) %>%
  select(FATALITIES) %>%
  summarize(total_fatalities = sum(FATALITIES)) %>%
  ggplot(aes(total_fatalities, year, fill = total_fatalities)) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~EVTYPE, scales = "free")

Storm events that cause severe economic damage

In order to calculate total damages from both crop damage and property damage, we cannot add the crop damage and property damage values because the CROPDMGEXP and PROPDMGEXP variables take values K, M and B to indicate damage in thousands of US dollars, millions of US dollars and billions of US dollars respectively. Hence the amounts need to be converted to thousands, millions and billions and then added to get the total damage value. Defined two new variables cropdmg and propdmg using case_when inside mutate converting the values to corresponding thousands, millions and billions. Selecting the EVTYPE and the two newly created variables, grouping by EVTYPE variable and calculating the total damage for each storm event by adding the cropdmg and propdmg values. Arranging the new data set obtained by total damage values in descending order, selecting the top twelve rows and plotting them against storm event type.

storm_data %>%
  mutate(cropdmg = case_when(
    CROPDMGEXP == "K" ~ CROPDMG * 1000,
    CROPDMGEXP == "M" ~ CROPDMG * 1e6,
    CROPDMGEXP == "B" ~ CROPDMG * 1e9,
    .default = 0),
    propdmg = case_when(
      PROPDMGEXP == "K" ~ PROPDMG * 1000,
      PROPDMGEXP == "M" ~ PROPDMG * 1e6,
      PROPDMGEXP == "B" ~ PROPDMG * 1e9,
      .default = 0)
    ) %>%
  filter(cropdmg > 0, propdmg > 0) %>%
  select(EVTYPE, cropdmg, propdmg) %>%
  group_by(EVTYPE) %>%
  summarize(total_dmgs = sum(cropdmg + propdmg)) %>%
  arrange(desc(total_dmgs)) %>%
  head(n=12) %>%
  ggplot(aes(total_dmgs/1e9, reorder(EVTYPE, total_dmgs), fill = EVTYPE)) +
  geom_col(show.legend = FALSE) +
  labs(x = "Total damages (billion USD)", y = "Storm Event")

From the plot, we see that flood has been the most destructive event causing extreme damage till date.
Futher the top five storm events that have caused the most economic damage are

  • FLOODS
  • HURRICANE/TYPHOON
  • HURRICANE
  • FLASHFLOOD
  • HAIL