Summary and Goals

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 are going to answer the two below questions utilizing this database.

Data Processing

Loading Data

First let’s load our raw storm data and take a look at a quick summary using str(). The read.csv() function has the ability to unzip bz2 files built into it so no need for extra work from that.

storms <- read.csv("repdata-data-StormData.csv.bz2")
str(storms)
## '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 ""," Christiansburg",..: 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 ""," CANTON"," TULIA",..: 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","%SD",..: 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/ 436781 levels "","\t","\t\t",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...

We can see our data consists of 37 variables representing a wide swath of data on nearly 1 million observations of various weather events in the United States.

Results

Our first question we want to address is which type of event (represented by the EVTYPE column) causes the greatest amount of damange in terms of human cost. The two variables o finterest are the FATALITIES and INJURIES. We use ddply() from the plyr package in order to split-apply-combine our data based on the EVTYPE column, summarize the total amount of fatalities and injuries per type of event. I also used the mutate() function from dplyr in order to add a column that sums these two numbers. I have displayed the top 25 results in terms of the total human cost (injuries and deaths added together, weighted equally).

library(plyr)
library(dplyr)
sum <- ddply(storms, "EVTYPE", summarize, sumfat = sum(FATALITIES), suminj = sum(INJURIES))
FinSub <- tbl_df(sum[sum$sumfat+sum$suminj != 0 ,])
FinSub <- arrange(mutate(FinSub, Injuries_Deaths = sumfat + suminj), desc(Injuries_Deaths))
head(FinSub, 25)
## Source: local data frame [25 x 4]
## 
##               EVTYPE sumfat suminj Injuries_Deaths
## 1            TORNADO   5633  91346           96979
## 2     EXCESSIVE HEAT   1903   6525            8428
## 3          TSTM WIND    504   6957            7461
## 4              FLOOD    470   6789            7259
## 5          LIGHTNING    816   5230            6046
## 6               HEAT    937   2100            3037
## 7        FLASH FLOOD    978   1777            2755
## 8          ICE STORM     89   1975            2064
## 9  THUNDERSTORM WIND    133   1488            1621
## 10      WINTER STORM    206   1321            1527
## ..               ...    ...    ...             ...

As we can see, in terms of human cost, tornadoes, excessive heat, wind and flooding are the worst.
Next we wanted to examine the economic consequences, so I followed the same procedure as before but this time looking at the sums of Property and Crop damage. Once again I have displayed the top 25 results based on total damage.

sum2 <- ddply(storms, "EVTYPE", summarize, SumProp = sum(PROPDMG), SumCrop = sum(CROPDMG))
FinSub2 <- tbl_df(sum2[sum2$SumProp+sum2$SumCrop != 0 ,])
FinSub2 <- arrange(mutate(FinSub2, Total_Econ = SumProp + SumCrop), desc(Total_Econ))
head(FinSub2, 25)
## Source: local data frame [25 x 4]
## 
##                EVTYPE   SumProp   SumCrop Total_Econ
## 1             TORNADO 3212258.2 100018.52  3312276.7
## 2         FLASH FLOOD 1420124.6 179200.46  1599325.1
## 3           TSTM WIND 1335965.6 109202.60  1445168.2
## 4                HAIL  688693.4 579596.28  1268289.7
## 5               FLOOD  899938.5 168037.88  1067976.4
## 6   THUNDERSTORM WIND  876844.2  66791.45   943635.6
## 7           LIGHTNING  603351.8   3580.61   606932.4
## 8  THUNDERSTORM WINDS  446293.2  18684.93   464978.1
## 9           HIGH WIND  324731.6  17283.21   342014.8
## 10       WINTER STORM  132720.6   1978.99   134699.6
## ..                ...       ...       ...        ...

I thought it would be an interesting to visualize our data by creating a scatterplot of events with their human and economic cost. We joined our two tables using the merge() function and then selected our the pertinent columns, being the event type and the sums of economic and human cost. We next made a scatterplot using the top 25 events when ranked by economic damage.

J <- arrange(merge(FinSub, FinSub2, by = "EVTYPE"), desc(Total_Econ, Injuries_Deaths))
J2 <- select(J, c(1,4,7))
with(J[1:25,], plot(Injuries_Deaths, Total_Econ), pch = ".")
with(J[1:25,], text(Injuries_Deaths, Total_Econ, labels = EVTYPE, cex = 0.5, pos = 1))

Whoa, looks like tornados are far and away the most expensive type of disaster in terms of economic and human cost. Lets get rid of that one and zoom in on the bottom corner of our graph.

with(J[2:25,], plot(Injuries_Deaths, Total_Econ), pch = ".")
with(J[2:25,], text(Injuries_Deaths, Total_Econ, labels = EVTYPE, cex = 0.5, pos = 1))

Now we have a better idea of our top 10 but outside of that things get all bunched up in the corner. Lets zoom in on those values.

with(J[20:30,], plot(Injuries_Deaths, Total_Econ), pch = ".")
with(J[20:30,], text(Injuries_Deaths, Total_Econ, labels = EVTYPE, cex = 0.5, pos = 1))

Ok now we can see the values ranked 20-30 a bit more spaced out. Surprisingly, one of the most widely played up disasters in the media, hurricanes, are not too high on the list. When we think about our results, they make sense. The characteristics of tornadoes are that they begin and end suddenly (often times lasting merely minutes), they are difficult to predict, they have ultra-high wind speeds and they occur relatively often. For these reasons, it totally makes sense tornadoes would be number 1. When we look at our other most costly weather events, one thing in particular sticks out to me. THe majority of these events are not very rapid like tornadoes, they tend to come on slow, accumulate and cause lasting damages. Examples of this are floods and wind from thunderstorms.