Synopsis

The basic goal of this assignment is to explore the NOAA Storm Database and answer some basic questions about severe weather events. The database will be analyzed to answer two questions: 1. Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health? 2. Across the United States, which types of events have the greatest economic consequences?

Data Processing

The dataset should be downloaded from the url link and be placed in the working directory. The data should be assigned a variable to be read into to utilize the read.table function. The data and the documentation are provided here:

Data set (https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2) Storm Data Documentation (https://d396qusza40orc.cloudfront.net/repdata%2Fpeer2_doc%2Fpd01016005curr.pdf) FAQ (https://d396qusza40orc.cloudfront.net/repdata%2Fpeer2_doc%2FNCDC%20Storm%20Events-FAQ%20Page.pdf)

library(R.utils)
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.6.1 (2014-01-04) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.18.0 (2014-02-22) 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 v1.33.0 (2014-08-24) 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(reshape2)
library(xtable)
library(knitr)
data <- read.table("repdata-data-StormData.csv", header=TRUE, sep=",")

Lets take a look at how many of each climatic event types has occured most freqently. Note: there are 985 different types of recorded event types. We will examine the dataset and assign the top 20 most fatal weather events. We will use the aggregate function to collapse the listings into our desired info needed to answer our given questions

data.fatal <-aggregate(data$FATALITIES, by=list(data$EVTYPE), FUN ="sum")
data.fatal = subset(data.fatal, data.fatal$x>0)
data.fatal <- data.fatal[order(data.fatal$x, decreasing = TRUE), ]
names(data.fatal)[1]="EVENT"
names(data.fatal)[2]="FATALITIES"
rownames(data.fatal)<-NULL
data.fatal <- data.fatal[1:20,]
data.injur <-aggregate(data$INJURIES, by=list(data$EVTYPE), FUN="sum")
data.injur = subset(data.injur, data.injur$x>0)
data.injur <- data.injur[order(data.injur$x, decreasing = TRUE), ]
names(data.injur)[1]="EVENT"
names(data.injur)[2]="INJURIES"
rownames(data.injur)<-NULL
data.injur <- data.injur[1:20,]
data.total=merge(data.fatal,data.injur, by.x="EVENT")
data.total <- data.total[order(data.total$FATALITIES,data.total$INJURIES, decreasing = TRUE), ]
rownames(data.total)<-NULL
data.total.M <- melt(data.total)
## Using EVENT as id variables
data.total.M <- data.total.M[order(data.total.M$value, decreasing = TRUE), ]
rownames(data.total.M)<-NULL
data.econ <-aggregate(cbind(data$PROPDMG,data$CROPDMG), by=list(data$EVTYPE), FUN="sum")
names(data.econ)[1]="EVENT"
names(data.econ)[2]="PROPDMG"
names(data.econ)[3]="CROPDMG"
data.econ <- subset(data.econ, CROPDMG > 0 | PROPDMG > 0)
data.econ <- data.econ[order(data.econ$PROPDMG,data.econ$CROPDMG, decreasing = TRUE), ]
data.econ <- data.econ[1:20,]
rownames(data.econ)<-NULL
data.econ.M <- melt(data.econ)
## Using EVENT as id variables
data.econ.M <- data.econ.M[order(data.econ.M$value, decreasing = TRUE), ]

Results

Tornados present to be the most harmful in regards to population health

data.total$total <- with(data.total, FATALITIES + INJURIES)
names(data.total) <- c("Event", "Fatalities", "Injuries", "Total")
kable(data.total)
## 
## 
## |Event             | Fatalities| Injuries| Total|
## |:-----------------|----------:|--------:|-----:|
## |TORNADO           |       5633|    91346| 96979|
## |EXCESSIVE HEAT    |       1903|     6525|  8428|
## |FLASH FLOOD       |        978|     1777|  2755|
## |HEAT              |        937|     2100|  3037|
## |LIGHTNING         |        816|     5230|  6046|
## |TSTM WIND         |        504|     6957|  7461|
## |FLOOD             |        470|     6789|  7259|
## |HIGH WIND         |        248|     1137|  1385|
## |WINTER STORM      |        206|     1321|  1527|
## |THUNDERSTORM WIND |        133|     1488|  1621|
## |HEAVY SNOW        |        127|     1021|  1148|
## |BLIZZARD          |        101|      805|   906|
barplot(data.total$Total, xlab ="Event", main="Weather events leading to the most damage to human health", pch =19, col ="blue", horiz = TRUE, names.arg= "Event Type")

plot of chunk unnamed-chunk-5

With respect to health, Tornados also present a the highest economic consequence

data.econ$total <- with(data.econ, PROPDMG + CROPDMG)
names(data.econ) <- c("Event", "Property Damage (Millions USD)", "Crop Damage (Millions USD)", "Total Damage (Millions USD)")
kable(data.econ)
## 
## 
## |Event                | Property Damage (Millions USD)| Crop Damage (Millions USD)| Total Damage (Millions USD)|
## |:--------------------|------------------------------:|--------------------------:|---------------------------:|
## |TORNADO              |                        3212258|                     100019|                     3312277|
## |FLASH FLOOD          |                        1420125|                     179200|                     1599325|
## |TSTM WIND            |                        1335966|                     109203|                     1445168|
## |FLOOD                |                         899938|                     168038|                     1067976|
## |THUNDERSTORM WIND    |                         876844|                      66791|                      943636|
## |HAIL                 |                         688693|                     579596|                     1268290|
## |LIGHTNING            |                         603352|                       3581|                      606932|
## |THUNDERSTORM WINDS   |                         446293|                      18685|                      464978|
## |HIGH WIND            |                         324732|                      17283|                      342015|
## |WINTER STORM         |                         132721|                       1979|                      134700|
## |HEAVY SNOW           |                         122252|                       2166|                      124418|
## |WILDFIRE             |                          84459|                       4364|                       88824|
## |ICE STORM            |                          66001|                       1689|                       67690|
## |STRONG WIND          |                          62994|                       1617|                       64611|
## |HIGH WINDS           |                          55625|                       1760|                       57385|
## |HEAVY RAIN           |                          50842|                      11123|                       61965|
## |TROPICAL STORM       |                          48424|                       5899|                       54323|
## |WILD/FOREST FIRE     |                          39345|                       4190|                       43534|
## |FLASH FLOODING       |                          28497|                       5126|                       33623|
## |URBAN/SML STREAM FLD |                          26052|                       2794|                       28846|