Title: “Peer Grade Assignment: Course Project 2 Impact of Natural Disasters on Population Health and Economy”

Synopsis

This study analyzes the NOAA storm database (between January 1950 and March 2016) comprises severe weather events on damage to property and lives. The purpose of this study to findout total fatalities, injuries, damages by event type and impact of events on people’s lives and economy.

Data Processing

1.Downloading the datafile

setwd("/Users/innugantii/Desktop/Indu/Coursera/Course 5")
if (!"StormData.csv.bz2" %in% dir("./")) {
    print("Downloading File.....")
    download.file("http://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2", destfile = "StormData.csv.bz2")
}

Reading CSV file

if (!"storm" %in% ls()) {
    storm <- read.csv(bzfile("StormData.csv.bz2"), sep = ",", header = TRUE, stringsAsFactors = FALSE)
}
dim(storm)
## [1] 902297     37
head(storm)
##   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
  1. Across the United States, which types of events are most harmful with respect to population health Compute combined economic damage (property damage + crops damage)
# Changing invalid Property Damage EXP and CROP Damage EXP to 0
storm$PROPDMGEXP <- ifelse(storm$PROPDMGEXP %in% c("B", "h", "H", "K", "m", "M"), as.character(storm$PROPDMGEXP),"NONE")
storm$CROPDMGEXP <- ifelse(storm$CROPDMGEXP %in% c("B", "k", "K", "m", "M"),  as.character(storm$CROPDMGEXP), "NONE")

# Multiplying property and crops damage by 10 raised to the power of the exponent
storm$PROPDMG <- storm$PROPDMG * (10^9 * (storm$PROPDMGEXP == "B") + 10^6 *(storm$PROPDMGEXP %in% c("m", "M")) + 10^3 * (storm$PROPDMGEXP %in% c("k", "K")) + 100 * (storm$PROPDMGEXP %in% c("h", "H")))
# Compute combined economic damage (property damage + crops damage)
storm$CROPDMG <- storm$CROPDMG * (10^9 * (storm$CROPDMGEXP == "B") + 10^6 *(storm$CROPDMGEXP %in% c("m", "M")) + 10^3 * (storm$CROPDMGEXP %in% c("k", "K")) + 100 * (storm$CROPDMGEXP %in% c("h", "H")))

## Combination of PROP and CROP damage
storm$PROPandCROP <- storm$PROPDMG + storm$CROPDMG

Total Number of Fatalities (by Event Type)

# Total number of fatalites by event type
 total_fatalities <- by(storm$FATALITIES, storm$EVTYPE, sum)
 
 #  Plots
 layout(matrix(c(1,2,1,2), 2, 2, byrow=T))
 
 # Top 10 Total fatalities by event type
 
 par(mar=c(5, 12, 4, 2))
 par(bg = 'lemonchiffon')
 barplot(sort(by(storm$FATALITIES, storm$EVTYPE, sum), decreasing=T)[10:1], horiz=T, las=1,cex.names=0.7,xlab="Fatalities Per Event Type")                          
 mtext("Top 10 Fatalities\n by Event Type", side=3, line=1, cex=1, at=1500, font=2)
 
# Top 10 Average number of fatalities by event type 
mean_fatalities <- by(storm$FATALITIES, storm$EVTYPE, mean)

# Top 10 Injuries by event
par(mar=c(5, 12, 4, 2))
par(bg = 'lemonchiffon')
barplot(sort(by(storm$FATALITIES, storm$EVTYPE, mean), decreasing=T)[10:1], horiz=T, 
las=1, cex.names=0.7, xlab="Ave Number of Injuries\n by Event")
mtext("Top 10 Injuries\n by Event Type ", side=3, line=1, cex=1, at=8, font=2)

Total Property Damage

layout(matrix(c(1,2,1,2), 2, 2, byrow=T))
 
 # Plotting Total damage
total_damage <- by(storm$PROPandCROP/10e9, storm$EVTYPE, sum)

 par(mar=c(5, 12, 4, 2))
 par(bg = 'aliceblue')
 barplot(sort(by(storm$PROPandCROP/10e9, storm$EVTYPE, sum), decreasing=T)[10:1], horiz=T, las=1, cex.names=0.7, xlab="Total Cost of Damage(Billions)\n By Event Type")
 mtext("Top 10 Damages\n By Event Type", side=3, line=1, cex=1, at=4, font=2)

# Plotting Damage by Event
mean_damage <- by(storm$PROPandCROP/10e6, storm$EVTYPE, mean)

 par(mar=c(5, 12, 4, 2))
 par(bg = 'aliceblue')
 barplot(sort(by(storm$PROPandCROP/10e6, storm$EVTYPE, mean), decreasing=T)[10:1], horiz=T, las=1, cex.names=0.7, xlab="Cost of Damage(Millions)\n by Event")
 mtext("Top 10 Damages\n by Event", side=3, line=1, cex=1, at=50, font=2)

Conclusion

From this analysis, we can infer that Excessive Heat and Tornadoes are most harmful to people lives and Flood, Drought and Hurricane/Typhoon caused the damage to properties.