Synopsis
The goal of the assignment is to explore the NOAA Storm Database and explore the effects of severe weather events on both population and economy.
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.
We will use the estimates of fatalities, injuries, property and crop damage to decide which types of event are most harmful to the population health and economy.
We concluded following
1) For injuries as well as fatal events, the most devastating events are tornados in the given time period.
2) Flood causes the highest property damage whereas draught causes highest crop damages and flood results in the highest total damage.
Installing necessary libraries
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(R.utils)
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.7.1 (2016-02-15) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.21.0 (2016-10-30) successfully loaded. See ?R.oo for help.
##
## Attaching package: 'R.oo'
## The following objects are masked from 'package:methods':
##
## getClasses, getMethods
## The following objects are masked from 'package:base':
##
## attach, detach, gc, load, save
## R.utils v2.5.0 (2016-11-07) successfully loaded. See ?R.utils for help.
##
## Attaching package: 'R.utils'
## The following object is masked from 'package:utils':
##
## timestamp
## The following objects are masked from 'package:base':
##
## cat, commandArgs, getOption, inherits, isOpen, parse, warnings
library(ggplot2)
library(plyr)
##
## Attaching package: 'plyr'
## The following object is masked from 'package:lubridate':
##
## here
library(gridExtra)
library(grid)
Data Processing
First we downloaded the file by clicking on the link ‘Storm Data’, then unzipped it. Subsequently, we read the CSV file using ‘read.csv’ command. As the storm data has 902297 rows with 37 columns,I tried to understand only first 2 rows with 37 columns using ‘head’ command.In my attempt to dig further information about the data, I employed ‘str’ command.
setwd("F:/Storm")
bunzip2("StormData.csv.bz2", overwrite=T, remove=F)
storm <- read.csv("StormData.csv", sep = ",")
dim(storm)
## [1] 902297 37
head(storm,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
## EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END
## 1 TORNADO 0 0
## 2 TORNADO 0 0
## COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1 NA 0 14 100 3 0 0
## 2 NA 0 2 150 2 0 0
## INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1 15 25.0 K 0
## 2 0 2.5 K 0
## LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1 3040 8812 3051 8806 1
## 2 3042 8755 0 0 2
str(storm)
## 'data.frame': 902297 obs. of 37 variables:
## $ STATE__ : num 1 1 1 1 1 1 1 1 1 1 ...
## $ BGN_DATE : Factor w/ 16335 levels "1/1/1966 0:00:00",..: 6523 6523 4242 11116 2224 2224 2260 383 3980 3980 ...
## $ BGN_TIME : Factor w/ 3608 levels "00:00:00 AM",..: 272 287 2705 1683 2584 3186 242 1683 3186 3186 ...
## $ TIME_ZONE : Factor w/ 22 levels "ADT","AKS","AST",..: 7 7 7 7 7 7 7 7 7 7 ...
## $ COUNTY : num 97 3 57 89 43 77 9 123 125 57 ...
## $ COUNTYNAME: Factor w/ 29601 levels "","5NM E OF MACKINAC BRIDGE TO PRESQUE ISLE LT MI",..: 13513 1873 4598 10592 4372 10094 1973 23873 24418 4598 ...
## $ STATE : Factor w/ 72 levels "AK","AL","AM",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ EVTYPE : Factor w/ 985 levels " HIGH SURF ADVISORY",..: 834 834 834 834 834 834 834 834 834 834 ...
## $ BGN_RANGE : num 0 0 0 0 0 0 0 0 0 0 ...
## $ BGN_AZI : Factor w/ 35 levels ""," N"," NW",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ BGN_LOCATI: Factor w/ 54429 levels "","- 1 N Albion",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ END_DATE : Factor w/ 6663 levels "","1/1/1993 0:00:00",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ END_TIME : Factor w/ 3647 levels ""," 0900CST",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ 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 : Factor w/ 24 levels "","E","ENE","ESE",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ END_LOCATI: Factor w/ 34506 levels "","- .5 NNW",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ 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: 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 ...
## $ WFO : Factor w/ 542 levels ""," CI","$AC",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ STATEOFFIC: Factor w/ 250 levels "","ALABAMA, Central",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ ZONENAMES : Factor w/ 25112 levels ""," "| __truncated__,..: 1 1 1 1 1 1 1 1 1 1 ...
## $ 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 : Factor w/ 436774 levels "","-2 at Deer Park\n",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ REFNUM : num 1 2 3 4 5 6 7 8 9 10 ...
Analysing Event Trackdown Data using Histogram
To analyse this, we need to convert the column ‘BGN_DATE’ into numeric year.
storm$year <- year(as.POSIXlt(storm$BGN_DATE,format = "%m/%d/%Y %H:%M:%S"))
hist(storm$year, breaks = 30, border = "black", col = "orange", xlab = "Year",main = "Histogram of Yearwise Storm Data")

It can be inferred from above histogram that frequency of number of events tracked increases from the year 1995 significantly.
As the questions asked are only pertaining to health & economic consequences, we can further trim down “storm”
stormrefined <- storm[,c("EVTYPE","FATALITIES","INJURIES","PROPDMG","PROPDMGEXP","CROPDMG","CROPDMGEXP","year")]
dim(stormrefined)
## [1] 902297 8
Code for answering question ‘Does the analysis address the question of which types of events are most harmful to population health ?’
harmpophealth <- ddply(stormrefined,.(EVTYPE),summarise,fatalities = sum(FATALITIES), injuries = sum(INJURIES))
fatal <- harmpophealth[order(harmpophealth$fatalities,decreasing = TRUE),]
injury <- harmpophealth[order(harmpophealth$injuries,decreasing = TRUE),]
As columns ‘PROPDMGEXP’ & ‘CROPDMGEXP’ are expressed with letters K(i.e. Thousands), L (i.e. Lacs),M ( i.e. Millions), B(i.e. Billions), it is required to convert the letter value of the exponent to a usable number employing following function.
damageamount <- function(amount,magnitude){
returnAmount <- 0
if(toupper(magnitude)[1]=="K")
{
returnAmount <- (amount*1000)
}
if(toupper(magnitude)[1]=="M")
{
returnAmount <- (amount*1000000)
}
if(toupper(magnitude)[1]=="B")
{
returnAmount <- (amount*1000000000)
}
return(returnAmount)
}
Using the above function, property and crop damage amounts can be calculated.
Code for answering the question ‘Does the analysis address the question of which types of events have the greatest economic consequences ?’
damagedata <- subset(stormrefined,PROPDMG >0 | CROPDMG >0)
damagedata$PropDamageamount <- mapply(damageamount,damagedata$PROPDMG,damagedata$PROPDMGEXP)
damagedata$CropDamageamount <- mapply(damageamount,damagedata$CROPDMG,damagedata$CROPDMGEXP)
damagedata$Damageamount <- ((mapply(damageamount,damagedata$PROPDMG,damagedata$PROPDMGEXP))+(mapply(damageamount,damagedata$CROPDMG,damagedata$CROPDMGEXP)))
Proptotaldamage <- ddply(damagedata,.(EVTYPE),summarise, Totalpropdamageamount=sum(PropDamageamount))
Croptotaldamage <- ddply(damagedata,.(EVTYPE),summarise, Totalcropdamageamount=sum(CropDamageamount))
totaldamage <- ddply(damagedata,.(EVTYPE),summarise, Totalamount=sum(Damageamount))
Proptotaldamage <- Proptotaldamage[order(Proptotaldamage$Totalpropdamageamount,decreasing = T),]
Croptotaldamage <- Croptotaldamage[order(Croptotaldamage$Totalcropdamageamount,decreasing = T),]
totaldamage <- totaldamage[order(totaldamage$Totalamount, decreasing = T),]
RESULTS
Quesion 1 – Does the analysis address the question of which types of events are most harmful to population health ?
head(fatal[,c("EVTYPE","fatalities")])
## EVTYPE fatalities
## 834 TORNADO 5633
## 130 EXCESSIVE HEAT 1903
## 153 FLASH FLOOD 978
## 275 HEAT 937
## 464 LIGHTNING 816
## 856 TSTM WIND 504
head(injury[,c("EVTYPE","injuries")])
## EVTYPE injuries
## 834 TORNADO 91346
## 856 TSTM WIND 6957
## 170 FLOOD 6789
## 130 EXCESSIVE HEAT 6525
## 464 LIGHTNING 5230
## 275 HEAT 2100
Answer for Question 1
For injuries as well as fatal events, the most devastating events are tornados in the given time period.
Question 2 – Does the analysis address the question of which types of events have the greatest economic consequences ?
head(Proptotaldamage)
## EVTYPE Totalpropdamageamount
## 72 FLOOD 144657709800
## 197 HURRICANE/TYPHOON 69305840000
## 354 TORNADO 56937160480
## 299 STORM SURGE 43323536000
## 59 FLASH FLOOD 16140811510
## 116 HAIL 15732266720
head(Croptotaldamage)
## EVTYPE Totalcropdamageamount
## 39 DROUGHT 13972566000
## 72 FLOOD 5661968450
## 262 RIVER FLOOD 5029459000
## 206 ICE STORM 5022113500
## 116 HAIL 3025954450
## 189 HURRICANE 2741910000
head(totaldamage)
## EVTYPE Totalamount
## 72 FLOOD 150319678250
## 197 HURRICANE/TYPHOON 71913712800
## 354 TORNADO 57352113590
## 299 STORM SURGE 43323541000
## 116 HAIL 18758221170
## 59 FLASH FLOOD 17562128610
Answer for Question 2
Inferring the above data, one can conclude that flood causes the highest property damage whereas draught causes highest crop damages and flood results in the highest total damage.