Introduction

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.

Load required packages

library(R.utils)
library(ggplot2)
library(dplyr)

Download Data

This code assumes that the data have already been downloaded to the working directory shown blelow

setwd("H:/WINDOWS/system")
StormData <- read.csv("H:/WINDOWS/System/repdata-data-StormData.csv.bz2")
head(StormData)
##   STATE__           BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1       1  4/18/1950 0:00:00     0130       CST     97     MOBILE    AL
## 2       1  4/18/1950 0:00:00     0145       CST      3    BALDWIN    AL
## 3       1  2/20/1951 0:00:00     1600       CST     57    FAYETTE    AL
## 4       1   6/8/1951 0:00:00     0900       CST     89    MADISON    AL
## 5       1 11/15/1951 0:00:00     1500       CST     43    CULLMAN    AL
## 6       1 11/15/1951 0:00:00     2000       CST     77 LAUDERDALE    AL
##    EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END
## 1 TORNADO         0                                               0
## 2 TORNADO         0                                               0
## 3 TORNADO         0                                               0
## 4 TORNADO         0                                               0
## 5 TORNADO         0                                               0
## 6 TORNADO         0                                               0
##   COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1         NA         0                      14.0   100 3   0          0
## 2         NA         0                       2.0   150 2   0          0
## 3         NA         0                       0.1   123 2   0          0
## 4         NA         0                       0.0   100 2   0          0
## 5         NA         0                       0.0   150 2   0          0
## 6         NA         0                       1.5   177 2   0          0
##   INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1       15    25.0          K       0                                    
## 2        0     2.5          K       0                                    
## 3        2    25.0          K       0                                    
## 4        2     2.5          K       0                                    
## 5        2     2.5          K       0                                    
## 6        6     2.5          K       0                                    
##   LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1     3040      8812       3051       8806              1
## 2     3042      8755          0          0              2
## 3     3340      8742          0          0              3
## 4     3458      8626          0          0              4
## 5     3412      8642          0          0              5
## 6     3450      8748          0          0              6

Impact on Health

Economic Ramifications

The two types of data: PROPDMG, representing property damange and CROPDMG, representing crop damage. There are characters within the variables indicating how to convert to raw USD. H = Hundreds (x100), k = kilo (x1000), m = millions (x1,000,000), b = billions (x1,000,000,000), + = x1, - = x0, ? = x0, blank space = x0.

The following chunk of code using the index values to convert to total USD of damages for both PROPDMG and CROPDMG. The DMG_TOTAl variable is the sum of both CROPDMG and PROPDMG.

StormData.Damage <- StormData %>% select(EVTYPE, PROPDMG,PROPDMGEXP,CROPDMG,CROPDMGEXP)
#Create a vector of the type of characters found in the PROPDMGEXP variable
characters <- sort(unique(as.character(StormData.Damage$PROPDMGEXP)))
#Create a vector to correct the damage variables 
correction <- c(0,0,0,1,10,10,10,10,10,10,10,10,10,10^9,10^2,10^2,10^3,10^6,10^6)
conversion.df <- data.frame(characters,correction)
#Adjust PROPDMG and CROPDMG based on indexed characters
StormData.Damage$PROP_ADJUST <- conversion.df$correction[match(StormData.Damage$PROPDMGEXP,conversion.df$characters)]
StormData.Damage$CROP_ADJUST <- conversion.df$correction[match(StormData.Damage$CROPDMGEXP,conversion.df$characters)]
StormData.Damage <- StormData.Damage %>% mutate(PROPDMG = PROPDMG*PROP_ADJUST) %>% mutate(CROPDMG = CROPDMG*CROP_ADJUST) %>% mutate(DMG_TOTAL = PROPDMG+CROPDMG)
StormData.TotalDamage <- StormData.Damage %>% group_by(EVTYPE) %>% summarise(DMG.EVTYPE.TOTAL=sum(DMG_TOTAL)) %>% arrange(-DMG.EVTYPE.TOTAL)
head(StormData.TotalDamage,10)
## # A tibble: 10 x 2
##    EVTYPE            DMG.EVTYPE.TOTAL
##    <fct>                        <dbl>
##  1 FLOOD                 150319678250
##  2 HURRICANE/TYPHOON      71913712800
##  3 TORNADO                57352117607
##  4 STORM SURGE            43323541000
##  5 FLASH FLOOD            17562132111
##  6 DROUGHT                15018672000
##  7 HURRICANE              14610229010
##  8 RIVER FLOOD            10148404500
##  9 ICE STORM               8967041810
## 10 TROPICAL STORM          8382236550

Results

The following chunk of code creates a bargraph for the 10 events with highest total fatalities

fatalities <- ggplot(StormData.fatal[1:10,], aes(x=reorder(EVTYPE, -Total_Fatalities), y=Total_Fatalities))+
    geom_bar(stat="identity")+ 
    theme(axis.text.x = element_text(angle=90, vjust=0.5, hjust=1))+
    ggtitle("Total Fatalities:  Top 10 Events") +labs(x="Type of Event", y="Total Fatalities")+
    theme(axis.text.x = element_text(colour="grey20",size=12,angle=45,hjust=.5,vjust=.5,face="bold"),
          axis.text.y = element_text(colour="grey20",size=12,angle=0,hjust=1,vjust=0,face="bold"),  
          axis.title.x = element_text(colour="grey20",size=12,angle=0,hjust=.5,vjust=0,face="bold"),
          axis.title.y = element_text(colour="grey20",size=12,angle=90,hjust=.5,vjust=.5,face="bold"))+
    theme(panel.background = element_rect(fill = "lightblue",colour = "lightblue",size = 0.5))
fatalities

The following chunk of code creates a bargraph for the 10 events with highest total injuries

injuries <- ggplot(StormData.injuries[1:10,], aes(x=reorder(EVTYPE, -Total_Injuries), y=Total_Injuries))+
    geom_bar(stat="identity")+ 
    theme(axis.text.x = element_text(angle=90, vjust=0.5, hjust=1))+
    ggtitle("Total Injuries:  Top 10 Events") +labs(x="Type of Event", y="Total Injuries")+
    theme(axis.text.x = element_text(colour="grey20",size=12,angle=45,hjust=.5,vjust=.5,face="bold"),
          axis.text.y = element_text(colour="grey20",size=12,angle=0,hjust=1,vjust=0,face="bold"),  
          axis.title.x = element_text(colour="grey20",size=12,angle=0,hjust=.5,vjust=0,face="bold"),
          axis.title.y = element_text(colour="grey20",size=12,angle=90,hjust=.5,vjust=.5,face="bold"))+
    theme(panel.background = element_rect(fill = "lightblue",colour = "lightblue",size = 0.5))
injuries

The following chunk of code creates a bargraph for the 10 events with highest economic impact

damage <- ggplot(StormData.TotalDamage[1:10,], aes(x=reorder(EVTYPE, -DMG.EVTYPE.TOTAL), y=DMG.EVTYPE.TOTAL))+
    geom_bar(stat="identity")+ 
    theme(axis.text.x = element_text(angle=90, vjust=0.5, hjust=1))+
    ggtitle("Highest Economic Impact :  Top 10 Events") +labs(x="Type of Event", y="Total Economic Impact (USD)")+
    theme(axis.text.x = element_text(colour="grey20",size=12,angle=45,hjust=.5,vjust=.5,face="bold"),
          axis.text.y = element_text(colour="grey20",size=12,angle=0,hjust=1,vjust=0,face="bold"),  
          axis.title.x = element_text(colour="grey20",size=12,angle=0,hjust=.5,vjust=0,face="bold"),
          axis.title.y = element_text(colour="grey20",size=12,angle=90,hjust=.5,vjust=.5,face="bold"))+
    theme(panel.background = element_rect(fill = "lightblue",colour = "lightblue",size = 0.5))
damage