1. 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.

2. Loading Data

Loading libraries for data reading.

## Libraries
library(dplyr)
library(ggplot2)
library(knitr)

Loading data from zip file in the current directory. If it is not found, it is downloaded by the indicated URL.

## Download Data
filename1 <- "./repdata_data_StormData.csv.bz2"

if(!file.exists(filename1)){
    #zipname <- "repdata_data_activity.zip"
    fileURL <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
    download.file(fileURL, destfile = filename1, method = "curl")
    
}
rawdata <- read.csv(filename1)

tidydata <- select(rawdata,EVTYPE,FATALITIES:CROPDMGEXP) #Resumed data for analyses.
NAvalues <- sum(is.na(tidydata))

In the data there is 0 NA value in the data.

3. Data Processing

Processing data for analysis of most harmful eventy type with respect to population health.

tidydata <- group_by(tidydata,EVTYPE)

## Fatalities Processing Data
US_FTL <- summarise(tidydata,FTL = sum(FATALITIES))
US_FTL <- US_FTL %>% arrange(desc(FTL)) %>% mutate(FTLPER = FTL/sum(FTL)*100,FTLCUM = cumsum(FTLPER))

#Injuries Processing Data
US_INJ <- summarise(tidydata,INJ = sum(INJURIES))
US_INJ <- US_INJ %>% arrange(desc(INJ)) %>% mutate(INJPER = INJ/sum(INJ)*100,INJCUM = cumsum(INJPER))

Processing data for analysis of most harmful eventy type with respect of economic consequences. The factors used on PROPDMGEXP and CROPDMGEXP were correlated with multipliers described in this link.

# Economic Processing Data
tidydata <- ungroup(tidydata)
Econ_data <- select(tidydata,EVTYPE,PROPDMG,PROPDMGEXP,CROPDMG,CROPDMGEXP) # Economic Impact Data

Prop_factors <- data.frame(Factor = levels(Econ_data$PROPDMGEXP),Multiplier = c(rep(0,3),10^0,rep(10^1,9),10^9,10^2,10^2,10^3,10^6,10^6))

Crop_factors <- data.frame(Factor = levels(Econ_data$CROPDMGEXP),Multiplier = c(rep(0,2),rep(10^1,2),10^9,10^3,10^3,10^6,10^6))

Econ_data <- Econ_data %>% mutate(PROPDMG_T = PROPDMG*Prop_factors$Multiplier[match(Econ_data$PROPDMGEXP,Prop_factors$Factor)],CROPDMG_T = CROPDMG*Crop_factors$Multiplier[match(Econ_data$CROPDMGEXP,Crop_factors$Factor)],ECONDMG = PROPDMG_T + CROPDMG_T) %>% group_by(EVTYPE) # Added columns with total amount of properties damage (PROPDMG_T), total amount of crop damage (CROPDMG_T), and total amount of economic impact

Econ_Evtype <- summarise(Econ_data,EVTYPEDMG = sum(ECONDMG))
Econ_Evtype <- Econ_Evtype %>% arrange(desc(EVTYPEDMG)) %>% mutate(DMGPER = EVTYPEDMG/sum(EVTYPEDMG)*100) %>% mutate(DMGCUM = cumsum(DMGPER))

4. Results

ggplot(US_FTL[1:10,],aes(x=reorder(EVTYPE,FTLCUM)))+geom_col(aes(y=FTL))+labs(x = "Event Type", y = "Fatalities", title = "Fatalities in US by Type of Event")+theme_bw(base_size = 7)+scale_y_continuous(sec.axis = sec_axis(~./55, name = "Cumulative Fatalities in US [%]"))+geom_point(aes(y=FTLCUM*55),pch = 16, size = 2, color = "darkblue")+geom_path(aes(y=FTLCUM*55, group=1), colour="darkblue", lty=3, size=0.9)

The highest fatalities by event type. The parameters are:

head(US_FTL,10)
## # A tibble: 10 x 4
##    EVTYPE           FTL FTLPER FTLCUM
##    <fct>          <dbl>  <dbl>  <dbl>
##  1 TORNADO         4179  57.9    57.9
##  2 HEAT             701   9.71   67.6
##  3 TSTM WIND        295   4.09   71.7
##  4 LIGHTNING        241   3.34   75.0
##  5 FLASH FLOOD      226   3.13   78.1
##  6 EXCESSIVE HEAT   179   2.48   80.6
##  7 HEAT WAVE        172   2.38   83.0
##  8 EXTREME COLD     103   1.43   84.4
##  9 FLOOD            103   1.43   85.9
## 10 EXTREME HEAT      96   1.33   87.2
ggplot(US_INJ[1:10,],aes(x= reorder(EVTYPE,INJCUM)))+geom_col(aes(y=INJ))+labs(x = "Event Type", y = "Injuries", title = "Injuries in US by Type of Event")+theme_bw(base_size = 7)+scale_y_continuous(sec.axis = sec_axis(~./1000, name = "Cumulative Injuries in US [%]"))+geom_point(aes(y=INJCUM*1000),pch = 16, size = 2, color = "darkblue")+geom_path(aes(y=INJCUM*1000, group=1), colour="darkblue", lty=3, size=0.9)

The highest injuries by event type. The parameters are:

head(US_INJ,10)
## # A tibble: 10 x 4
##    EVTYPE               INJ INJPER INJCUM
##    <fct>              <dbl>  <dbl>  <dbl>
##  1 TORNADO            72055 82.7     82.7
##  2 TSTM WIND           3808  4.37    87.1
##  3 ICE STORM           1800  2.07    89.2
##  4 LIGHTNING           1578  1.81    91.0
##  5 THUNDERSTORM WINDS   908  1.04    92.0
##  6 HEAT                 878  1.01    93.0
##  7 HAIL                 730  0.838   93.9
##  8 BLIZZARD             596  0.684   94.6
##  9 EXCESSIVE HEAT       546  0.627   95.2
## 10 HEAVY SNOW           486  0.558   95.8
ggplot(Econ_Evtype[1:10,],aes(x=reorder(EVTYPE,DMGCUM)))+geom_col(aes(y=EVTYPEDMG/10^6))+labs(x = "Event Type", y = "Economic Damage [MiUSD]", title = "Economic Damage by Type of Event")+theme_bw(base_size = 7)+scale_y_continuous(sec.axis = sec_axis(~./350, name = "Cumulative Economic Damage in US [%]"))+geom_point(aes(y=DMGCUM*350),pch = 16, size = 2, color = "darkblue")+geom_path(aes(y=DMGCUM*350, group=1), colour="darkblue", lty=3, size=0.9)

The highest economic impacts by event type. The parameters are:

head(Econ_Evtype,10)
## # A tibble: 10 x 4
##    EVTYPE                      EVTYPEDMG DMGPER DMGCUM
##    <fct>                           <dbl>  <dbl>  <dbl>
##  1 TORNADO                   33556245357  39.1    39.1
##  2 RIVER FLOOD               10133367500  11.8    50.9
##  3 ICE STORM                  5416705150   6.31   57.2
##  4 WINTER STORM               5217677050   6.07   63.2
##  5 FLOOD                      3886654300   4.53   67.8
##  6 HURRICANE OPAL             3191846000   3.72   71.5
##  7 FLASH FLOOD                2564411401   2.99   74.5
##  8 HAIL                       2549130097   2.97   77.4
##  9 HEAVY RAIN/SEVERE WEATHER  2500000000   2.91   80.4
## 10 THUNDERSTORM WINDS         1926669872   2.24   82.6