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.

The storm events causing harms to population health and economic damage are analyzed below. The results indicate that tornadoes had caused the most injuries and fatalities among all weather events considered. On the other hand, floods had brought the greatest economic impact on properties. The crops were damaged mostly by river floods and icestorms between 1950 and 2011.

Data Processing

About the data

Refer to the documentation of the database to find the variables.

The events in the database start in the year 1950 and end in November 2011. In the earlier years of the database there are generally fewer events recorded, most likely due to a lack of good records. More recent years should be considered more complete.

Set options and load required packages

knitr::opts_chunk$set(warning=FALSE, fig.height=5, fig.width=10)
library(ggplot2)
library(gridExtra)

Load data and examine it

The bz2 zipped data was downloaded from the Reproducible Research course website. It is then loaded with read.csv command.

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

Structure of the data:

str(storm_data)
## 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : chr  "4/18/1950 0:00:00" "4/18/1950 0:00:00" "2/20/1951 0:00:00" "6/8/1951 0:00:00" ...
##  $ BGN_TIME  : chr  "0130" "0145" "1600" "0900" ...
##  $ TIME_ZONE : chr  "CST" "CST" "CST" "CST" ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: chr  "MOBILE" "BALDWIN" "FAYETTE" "MADISON" ...
##  $ STATE     : chr  "AL" "AL" "AL" "AL" ...
##  $ EVTYPE    : chr  "TORNADO" "TORNADO" "TORNADO" "TORNADO" ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : chr  "" "" "" "" ...
##  $ BGN_LOCATI: chr  "" "" "" "" ...
##  $ END_DATE  : chr  "" "" "" "" ...
##  $ END_TIME  : chr  "" "" "" "" ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : chr  "" "" "" "" ...
##  $ END_LOCATI: chr  "" "" "" "" ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: chr  "K" "K" "K" "K" ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: chr  "" "" "" "" ...
##  $ WFO       : chr  "" "" "" "" ...
##  $ STATEOFFIC: chr  "" "" "" "" ...
##  $ ZONENAMES : chr  "" "" "" "" ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : chr  "" "" "" "" ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...

Extract variables of interest

Appropriate variables were extracted from the dataset to answer the following questions:

  • Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?
  • Across the United States, which types of events have the greatest economic consequences?

These variables include:

  • EVTYPE: Type of weather event
  • FATALITIES: Number of deaths
  • INJURIES: Number of injuries
  • PROPDMG: Property damages
  • PROPDMGEXP: Units for property damage value
  • CROPDMG: Crop damages
  • CROPDMGEXP: Units for crop damage value
data <- storm_data[, c("EVTYPE", "FATALITIES", "INJURIES", "PROPDMG", "PROPDMGEXP", "CROPDMG", "CROPDMGEXP")]
head(data)
##    EVTYPE FATALITIES INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP
## 1 TORNADO          0       15    25.0          K       0           
## 2 TORNADO          0        0     2.5          K       0           
## 3 TORNADO          0        2    25.0          K       0           
## 4 TORNADO          0        2     2.5          K       0           
## 5 TORNADO          0        2     2.5          K       0           
## 6 TORNADO          0        6     2.5          K       0

Handling missing values and unifying units

It is clear that there are were entries in the units columns. Prior to dealing with them, the presence of missing values in the other numeric columns was checked for:

sum(is.na(data))
## [1] 0

Since there are none, only the units need to be dealt with.

sort(table(data$PROPDMGEXP))
## 
##      -      8      h      3      4      6      +      7      H      m      ? 
##      1      1      1      4      4      4      5      5      6      7      8 
##      2      1      5      B      0      M      K        
##     13     25     28     40    216  11330 424665 465934
sort(table(data$CROPDMGEXP))
## 
##      2      m      ?      B      0      k      M      K        
##      1      1      7      9     19     21   1994 281832 618413

Having different units makes the comparison of the values hard anyway, so unification of the different units was carried out following these rules:

  • B/b: billion dollars
  • M/m: million dollars
  • K/k: thousand dollars
  • H/h: hundred dollars
  • +: dollars
  • -: None
  • ?: None
  • Blank: None
# Replace the symbols by numerical exponents
data$PROPDMGEXP[grepl(pattern="B", x=data$PROPDMGEXP, ignore.case=TRUE)] <- 9
data$CROPDMGEXP[grepl(pattern="B", x=data$CROPDMGEXP, ignore.case=TRUE)] <- 9
data$PROPDMGEXP[grepl(pattern="M", x=data$PROPDMGEXP, ignore.case=TRUE)] <- 6
data$CROPDMGEXP[grepl(pattern="M", x=data$CROPDMGEXP, ignore.case=TRUE)] <- 6
data$PROPDMGEXP[grepl(pattern="K", x=data$PROPDMGEXP, ignore.case=TRUE)] <- 3
data$CROPDMGEXP[grepl(pattern="K", x=data$CROPDMGEXP, ignore.case=TRUE)] <- 3
data$PROPDMGEXP[grepl(pattern="H", x=data$PROPDMGEXP, ignore.case=TRUE)] <- 2
data$CROPDMGEXP[grepl(pattern="H", x=data$CROPDMGEXP, ignore.case=TRUE)] <- 2
data$PROPDMGEXP[grepl(pattern="\\+", x=data$PROPDMGEXP, ignore.case=TRUE)] <- 0
data$CROPDMGEXP[grepl(pattern="\\+", x=data$CROPDMGEXP, ignore.case=TRUE)] <- 0

# For entries without property or crop damage, replace with a small number
data$PROPDMGEXP[grepl(pattern="\\-", x=data$PROPDMGEXP, ignore.case=TRUE)] <- -3
data$CROPDMGEXP[grepl(pattern="\\-", x=data$CROPDMGEXP, ignore.case=TRUE)] <- -3
data$PROPDMGEXP[grepl(pattern="\\?", x=data$PROPDMGEXP, ignore.case=TRUE)] <- -3
data$CROPDMGEXP[grepl(pattern="\\?", x=data$CROPDMGEXP, ignore.case=TRUE)] <- -3
data$PROPDMGEXP[grepl(pattern="^$", x=data$PROPDMGEXP, ignore.case=TRUE)] <- -3
data$CROPDMGEXP[grepl(pattern="^$", x=data$CROPDMGEXP, ignore.case=TRUE)] <- -3

# Compute the damage values by raising 10 to the power of the exponents
data$PROPDMG <- data$PROPDMG * 10^as.numeric(data$PROPDMGEXP)
data$CROPDMG <- data$CROPDMG * 10^as.numeric(data$CROPDMGEXP)

# Filter out the small values as they are supposed to be zeros
data$PROPDMG[which(data$PROPDMG < 0.01)] <- 0
data$CROPDMG[which(data$PROPDMG < 0.01)] <- 0

Analysis

The total fatalities and total injuries as grouped by each event type are computed:

deaths <- aggregate(x=data$FATALITIES, by=list(data$EVTYPE), FUN=sum)
injuries <- aggregate(x=data$INJURIES, by=list(data$EVTYPE), FUN=sum)
names(deaths) <- c("Event_Type", "Death_Number")
names(injuries) <- c("Event_Type", "Injury_Number")

Followed by the total property and crop damages as grouped by each event type:

prop_dmg <- aggregate(x=data$PROPDMG, by=list(data$EVTYPE), FUN=sum)
crop_dmg <- aggregate(x=data$CROPDMG, by=list(data$EVTYPE), FUN=sum)
names(prop_dmg) <- c("Event_Type", "Property_Damage")
names(crop_dmg) <- c("Event_Type", "Crop_Damage")

The top 5 events that brought about each category were then extracted out:

deaths <- deaths[order(desc(deaths$Death_Number)), ][1:5, ]
injuries <- injuries[order(desc(injuries$Injury_Number)), ][1:5, ]
prop_dmg <- prop_dmg[order(desc(prop_dmg$Property_Damage)), ][1:5, ]
crop_dmg <- crop_dmg[order(desc(crop_dmg$Crop_Damage)), ][1:5, ]

Results

The top 5 events that had caused the most fatalities and injuries are shown below:

death_plt <- ggplot(data=deaths, aes(x=Event_Type, y=Death_Number, fill=Event_Type)) + 
  geom_bar(stat="identity", show.legend=FALSE) + 
  theme(axis.text.x=element_text(angle=30, hjust=1)) + 
  labs(x="Event Type", y="Total Number of Fatailities")
injury_plt <- ggplot(data=injuries, aes(x=Event_Type, y=Injury_Number, fill=Event_Type)) + 
  geom_bar(stat="identity", show.legend=FALSE) + 
  theme(axis.text.x=element_text(angle=30, hjust=1)) + 
  labs(x="Event Type", y="Total Number of Injuries")
grid.arrange(death_plt, injury_plt, ncol=2, top="Top 5 Events causing Fatalities and Injuries")

The top 5 events that had caused the most property and crop damages are shown below:

prop_plt <- ggplot(data=prop_dmg, aes(x=Event_Type, y=Property_Damage, fill=Event_Type)) + 
  geom_bar(stat="identity", show.legend=FALSE) + 
  theme(axis.text.x=element_text(angle=30, hjust=1)) + 
  labs(x="Event Type", y="Total Amount of Property Damage (Dollars)")
crop_plt <- ggplot(data=crop_dmg, aes(x=Event_Type, y=Crop_Damage, fill=Event_Type)) + 
  geom_bar(stat="identity", show.legend=FALSE) + 
  theme(axis.text.x=element_text(angle=30, hjust=1)) + 
  labs(x="Event Type", y="Total Amount of Crop Damage (Dollars)")
grid.arrange(prop_plt, crop_plt, ncol=2, top="Top 5 Events causing Property and Crop Damages")

Summary

It was concluded from the analysis that tornadoes had caused the greatest damage to population health while floods had the worst impact on the economy. Floods in general brought the most damages to properties while river floods and icestorms were the most dangerous for crops.