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.

This project explores 2 questions: 1. The types of events that are most harmful with respect to population health. 2. The types of events that have the greatest economics consequences.

Data Processing

Download data and read in as csv. Next we subset the data to grab the key elements that has economics consequences and health implications.

#download.file('https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2', destfile = 'Storm.csv.bz2', method = 'curl')
Storm = read.csv('Storm.csv.bz2',header = TRUE, sep = ",")

#review storm data
names(Storm)
##  [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"
head(Storm, nrow=2)
##   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
#subset data
SubStorm = Storm[, c('EVTYPE','FATALITIES','INJURIES','PROPDMG','PROPDMGEXP','CROPDMG','CROPDMGEXP')]
str(SubStorm)
## 'data.frame':    488189 obs. of  7 variables:
##  $ EVTYPE    : Factor w/ 974 levels "   HIGH SURF ADVISORY",..: 825 825 825 825 825 825 825 825 825 825 ...
##  $ 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: Factor w/ 19 levels "","-","?","+",..: 17 17 17 17 17 17 17 17 17 17 ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: Factor w/ 9 levels "","?","0","2",..: 1 1 1 1 1 1 1 1 1 1 ...

Next step is to convert the values under variables by mapping the values

library(plyr)
table(SubStorm$PROPDMGEXP)
## 
##             -      ?      +      0      1      2      3      4      5 
## 352019      1      8      5    215     25     13      4      4     28 
##      6      7      8      B      h      H      K      m      M 
##      4      5      1     15      1      6 129085      7   6743
tmpPROP=mapvalues(SubStorm$PROPDMGEXP, c("-","?","+", "0","1","2","3","4","5","6","7","8","B","h","H","K","m","M"," "),
          c(1,1, 1, 1,10, 10^2, 10^3,10^4,10^5,10^6,10^7,10^8,10^9, 10^2,10^2,10^3,10^6, 10^6,1))
## The following `from` values were not present in `x`:
table(SubStorm$CROPDMGEXP)
## 
##             ?      0      2      B      k      K      m      M 
## 469800      7     19      1      5     21  17275      1   1060
tmpCROP=mapvalues(SubStorm$CROPDMGEXP, c("?", "0","2","B","k","K","m","M"," "),
          c(1,1, 10^2, 10^9,10^3,10^3,10^6,10^6,1))
## The following `from` values were not present in `x`:
SubStorm$Tot_PropDMG = as.numeric(tmpPROP)*SubStorm$PROPDMG
SubStorm$Tot_CropDMG = as.numeric(tmpCROP)*SubStorm$CROPDMG

Results

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

library(ggplot2)
event = aggregate(FATALITIES ~ EVTYPE, SubStorm, sum)
str(event)
## 'data.frame':    974 obs. of  2 variables:
##  $ EVTYPE    : Factor w/ 974 levels "   HIGH SURF ADVISORY",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 0 0 ...
#get top 10 
event = event[order(event$FATALITIES, decreasing = T),][1:10,]

#factor the events to get descending order for graph
event$EVTYPE <- factor(event$EVTYPE, levels = event$EVTYPE)

ggplot(event, aes(x=EVTYPE, y= FATALITIES)) +
  geom_bar(stat = 'identity', fill = 'blue')+
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  xlab('Events')+
  ylab('Fatalities')+
  ggtitle('Events That Are Most Harmful with Respect to Population Health Across the US')

We can see that Tornado is the number one cause of most harmful event

Number of Injuries BY TOP 10 Wrather Events

Injuries = aggregate(INJURIES ~ EVTYPE, SubStorm, sum)
str(Injuries)
## 'data.frame':    974 obs. of  2 variables:
##  $ EVTYPE  : Factor w/ 974 levels "   HIGH SURF ADVISORY",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ INJURIES: num  0 0 0 0 0 0 0 0 0 0 ...
#get top 10 
Injuries = Injuries[order(Injuries$INJURIES, decreasing = T),][1:10,]

#factor the events to get descending order for graph
Injuries$EVTYPE <- factor(Injuries$EVTYPE, levels = Injuries$EVTYPE)

ggplot(Injuries, aes(x=EVTYPE, y= INJURIES)) +
  geom_bar(stat = 'identity', fill = 'red')+
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  xlab('Events')+
  ylab('Injuries')+
  ggtitle('Injuries By Top 10 Weather Events Across the US')

We can see that Tornado causes the most injuries as as the event that causes the most fatalities above

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

SubStorm$TotalDamage = SubStorm$Tot_CropDMG +SubStorm$Tot_PropDMG

DMG = aggregate(TotalDamage ~ EVTYPE, data=SubStorm, sum)
str(DMG)
## 'data.frame':    974 obs. of  2 variables:
##  $ EVTYPE     : Factor w/ 974 levels "   HIGH SURF ADVISORY",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ TotalDamage: num  1000 0 250 0 564 40 0 0 25 0 ...
DMG = DMG[order(DMG$TotalDamage, decreasing = T), ][1:10, ]
DMG$EVTYPE = factor(DMG$EVTYPE, levels = DMG$EVTYPE)

ggplot(DMG, aes(x = EVTYPE, y = TotalDamage/10^3)) + 
    geom_bar(stat = "identity", fill = "green") + 
    theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
    xlab("Event Type") + ylab("Damages (1k$)") + ggtitle("Property & Crop Damages(Total Damage) by top 10 Weather Events")

Conclusion: It appears that Tornado causes not only the most damage to human health but the economics damages as well.