1 Synopsis

Severe weather events like storms can lead to issues of public health and economy. In order to better understand which forms of such events do most harm to the US population health and domestic economy, this report analyses effects of severe weather events on well-being and economy in the US setting using the NOAA Storm Database, which covers a time period from 1950 to 2011 (Nov.). The Data could be downloaded from National Weather Service Storm Data Documentation. The health variable is defined as injuries and fatalities, whereas the variable of economic problems focuses on property and crops. In summary, while tornado, excessive heat, and TSTM wind are the Top 3 most harmful events to population health, flood, hurricane/typhoon, and tornado result in greatest economic consequences.

2 Data Processing

2.1 Data Loading

To load the data into R, we need three steps: (1) Open the library of “data.table” and “ggplot2” that are needed to transform the format of the downloaded raw data and to illustrate different effects of severe weather events; (2) Download the NOAA Storm Database from the given URL into RStudio, and rename it as “data” for simplicity; (3) Transform the data into the form that could be applied for data analysis.

# Open necessary libraries
library("data.table")
library("ggplot2")

# Download the data from the given URL into R
fileUrl <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(fileUrl, destfile = paste0("/Users/Heidi_Tang/Desktop", '/repdata%2Fdata%2FStormData.csv.bz2'))
data <- read.csv("/Users/Heidi_Tang/Desktop/repdata%2Fdata%2FStormData.csv.bz2")

# Convert data.frame to data.table
data <- as.data.table(data)

2.2 Examination of Variables’ Names

colnames(data)
##  [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"

2.3 Data-Subsetting

Produce a subset of the whole data that only contains variables of interest.

# Search for and mark the useful columns, and remove the useless columns
cols2Remove <- colnames(data[, !c("EVTYPE"
  , "FATALITIES"
  , "INJURIES"
  , "PROPDMG"
  , "PROPDMGEXP"
  , "CROPDMG"
  , "CROPDMGEXP")])

data[, c(cols2Remove) := NULL]

# Apply the data w.r.t fatalities and injuries  
data <- data[(EVTYPE != "?" & 
             (INJURIES > 0 | FATALITIES > 0 | PROPDMG > 0 | CROPDMG > 0)), c("EVTYPE"
                                                                            , "FATALITIES"
                                                                            , "INJURIES"
                                                                            , "PROPDMG"
                                                                            , "PROPDMGEXP"
                                                                            , "CROPDMG"
                                                                            , "CROPDMGEXP") ]

2.4 Converting Exponent Columns into Actual Exponents

Clean the columns of PROPDMGEXP and CROPDMGEXP to calculate property and crop costs.

# Change damage exponents to uppercase
cols <- c("PROPDMGEXP", "CROPDMGEXP")
data[,  (cols) := c(lapply(.SD, toupper)), .SDcols = cols]

# Map property damage alphanumeric exponents to numeric values
propDmgKey <-  c("\"\"" = 10^0,
                 "-" = 10^0, 
                 "+" = 10^0,
                 "0" = 10^0,
                 "1" = 10^1,
                 "2" = 10^2,
                 "3" = 10^3,
                 "4" = 10^4,
                 "5" = 10^5,
                 "6" = 10^6,
                 "7" = 10^7,
                 "8" = 10^8,
                 "9" = 10^9,
                 "H" = 10^2,
                 "K" = 10^3,
                 "M" = 10^6,
                 "B" = 10^9)

# Map crop damage alphanumeric exponents to numeric values
cropDmgKey <-  c("\"\"" = 10^0,
                "?" = 10^0, 
                "0" = 10^0,
                "K" = 10^3,
                "M" = 10^6,
                "B" = 10^9)

data[, PROPDMGEXP := propDmgKey[as.character(data[,PROPDMGEXP])]]
data[is.na(PROPDMGEXP), PROPDMGEXP := 10^0 ]

data[, CROPDMGEXP := cropDmgKey[as.character(data[,CROPDMGEXP])] ]
data[is.na(CROPDMGEXP), CROPDMGEXP := 10^0 ]

2.5 Adding Columns of Economic Costs

data <- data[, .(EVTYPE, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP, propCosts = PROPDMG * PROPDMGEXP, CROPDMG, CROPDMGEXP, cropCosts = CROPDMG * CROPDMGEXP)]

2.6 Calcuation of Total Property and Crop Costs

totalCostDT <- data[, .(propCosts = sum(propCosts), cropCosts = sum(cropCosts), Total_Costs = sum(propCosts) + sum(cropCosts)), by = .(EVTYPE)]

totalCostDT <- totalCostDT[order(-Total_Costs), ]

totalCostDT <- totalCostDT[1:10, ]

head(totalCostDT, 5)
##               EVTYPE    propCosts  cropCosts  Total_Costs
##               <char>        <num>      <num>        <num>
## 1:             FLOOD 144657709807 5661968450 150319678257
## 2: HURRICANE/TYPHOON  69305840000 2607872800  71913712800
## 3:           TORNADO  56947380677  414953270  57362333947
## 4:       STORM SURGE  43323536000       5000  43323541000
## 5:              HAIL  15735267513 3025954473  18761221986

2.7 Calcuation of Total Fatalities and Injuries

totalInjuriesDT <- data[, .(FATALITIES = sum(FATALITIES), INJURIES = sum(INJURIES), Total = sum(FATALITIES) + sum(INJURIES)), by = .(EVTYPE)]

totalInjuriesDT <- totalInjuriesDT[order(-FATALITIES), ]

totalInjuriesDT <- totalInjuriesDT[1:10, ]

head(totalInjuriesDT, 5)
##            EVTYPE FATALITIES INJURIES Total
##            <char>      <num>    <num> <num>
## 1:        TORNADO       5633    91346 96979
## 2: EXCESSIVE HEAT       1903     6525  8428
## 3:    FLASH FLOOD        978     1777  2755
## 4:           HEAT        937     2100  3037
## 5:      LIGHTNING        816     5230  6046

3 Results

3.1 Most Harmful Events to Public Health

Melt the data.table for the following bar graph.

bad_stuff <- melt(totalInjuriesDT, id.vars="EVTYPE", variable.name = "Outcomes")
head(bad_stuff, 5)
##            EVTYPE   Outcomes value
##            <char>     <fctr> <num>
## 1:        TORNADO FATALITIES  5633
## 2: EXCESSIVE HEAT FATALITIES  1903
## 3:    FLASH FLOOD FATALITIES   978
## 4:           HEAT FATALITIES   937
## 5:      LIGHTNING FATALITIES   816
# Create chart
healthChart <- ggplot(bad_stuff, aes(x=reorder(EVTYPE, -value), y=value))

# Plot the data as a bar chart
healthChart = healthChart + geom_bar(stat="identity", aes(fill=Outcomes), position="dodge")

# Label the y-axis and the x-axis
healthChart = healthChart + ylab("Absolute Frequency") 

healthChart = healthChart + xlab("Events") 

# Rotate x-axis tick labels 
healthChart = healthChart + theme(axis.text.x = element_text(angle=45, hjust=1))

# Set chart title and center it
healthChart = healthChart + ggtitle("Ten Most Harmful Events to Public Health") + theme(plot.title = element_text(hjust = 0.5))

healthChart

Question 1

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

Answer 1

  • The Top 3 harmful events are tornado, excessive heat, and TSTM wind.
  • The Top 4 to 10 harmful events are flood, lightning, heat, flash flood, high wind, RIP current, and avalanche.

3.2 Events with the Greatest Economic Costs

Melt the data.table for the following bar graph.

econ_consequences <- melt(totalCostDT, id.vars="EVTYPE", variable.name = "Outcomes")
head(econ_consequences, 5)
##               EVTYPE  Outcomes        value
##               <char>    <fctr>        <num>
## 1:             FLOOD propCosts 144657709807
## 2: HURRICANE/TYPHOON propCosts  69305840000
## 3:           TORNADO propCosts  56947380677
## 4:       STORM SURGE propCosts  43323536000
## 5:              HAIL propCosts  15735267513
# Create chart
econChart <- ggplot(econ_consequences, aes(x=reorder(EVTYPE, -value), y=value))

# Plot the data as bar chart
econChart = econChart + geom_bar(stat="identity", aes(fill=Outcomes), position="dodge")

# Label the y-axis and the x-axis
econChart = econChart + ylab("Costs (in US $)") 

econChart = econChart + xlab("Event") 

# Rotate the x-axis tick labels 
econChart = econChart + theme(axis.text.x = element_text(angle=45, hjust=1))

# Set chart title and center it
econChart = econChart + ggtitle("Events with the Greatest Economic Costs") + theme(plot.title = element_text(hjust = 0.5))

econChart

Question 2

Across the United States, which types of events have the greatest economic consequences?

Answer 2

  • The Top 3 events with the largest negative economic effects are flood, hurricane/typhoon, and tornado.
  • The Top 4 to 10 damaging events are storm surge, hail, flash flood, drought, hurricane, river flood, and ice storm.