This analysis seeks to address two questions: (1) Across the United States, which types of events are most harmful with respect to population health?, and (2) Across the United States, which types of events have the greatest economic consequences? Results indicate that volcanic ashfall and first frost have some of the greatest impacts on the health an economy in the United States.

Data Processing

In order to process the data, we must first set the working directory, load the CSV file, and examine the data to see which columns are relevant for our analysis.

setwd("~/Desktop/coursera")
WeatherData <- read.csv("repdata-data-StormData.csv")
names(WeatherData)
##  [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"

There are 37 columns and almost a million rows in this dataset. There are 985 unique event types of weather. We’re primarily interested in how EVTYPE (event type) and FATALITIES and INJURIES are related for health, and how PROPDMG and CROPDMG are related for economy. In order to make this data easier to deal with, I will make a smaller dataframe which summarizes these factors.

Events <- unique(WeatherData$EVTYPE)
fatality <- vector()
injury <- vector()
property <- vector()
crop <- vector()

for(i in 1:length(Events)){
   ftemp <- sum(WeatherData$FATALITIES[WeatherData$EVTYPE==Events[i]])
   itemp <- sum(WeatherData$INJURIES[WeatherData$EVTYPE==Events[i]])
   ptemp <- sum(WeatherData$FATALITIES[WeatherData$EVTYPE==Events[i]])
   ctemp <- sum(WeatherData$FATALITIES[WeatherData$EVTYPE==Events[i]])
   fatality <- append(ftemp,fatality)
   injury <- append(itemp, injury)
   property <- append(ptemp,property)
   crop <- append(ctemp, crop)
   }

NewData <- data.frame(Events, fatality, injury, property,crop)

Results

First, we will look at how different types of weather affect fatalities and injuries. Since we’re only interested in those with the biggest impact, we’ll just plot the top ten fatalities and top ten injuries. This makes a much cleaner graph than plotting all 985 event types.

par(mfrow=c(1,2))
NewData <- NewData[with(NewData, order(-fatality)),]
barplot(NewData$fatality[1:10], main="Top 10 Fatalities by Weather Type", ylab="total number of fatalities", xlab="weather type",col=heat.colors(10))
text(c(0:9)*1.2+.7,3000, labels=NewData$Events[1:10],cex=.8,srt=90)

NewData <- NewData[with(NewData, order(-injury)),]
barplot(NewData$injury[1:10], main="Top 10 Injuries by Weather Type", ylab="total number of injuries", xlab="weather type",col=heat.colors(10))
text(c(0:9)*1.2+.7,45000, labels=NewData$Events[1:10],cex=.8,srt=90)

From these two graphs, it is clear the event with the biggest impact on health is volcanic ashfall. This event has the highest number of injuries and deaths. First frost and tornado debris are also associated with fatalities. Astronomical low tide and non-TSTM wind are also associated with injuries.

Next, we will look at economic impact of various events.

par(mfrow=c(1,2))
NewData <- NewData[with(NewData, order(-property)),]
barplot(NewData$property[1:10], main="Top 10 Property Damage by Weather Type", ylab="total amount of damage", xlab="weather type",col=topo.colors(10))
text(c(0:9)*1.2+.7,3000, labels=NewData$Events[1:10],cex=.8,srt=90)

NewData <- NewData[with(NewData, order(-crop)),]
barplot(NewData$crop[1:10], main="Top 10 Crop Damage by Weather Type", ylab="total amount of damage", xlab="weather type",col=topo.colors(10))
text(c(0:9)*1.2+.7,2500, labels=NewData$Events[1:10],cex=.8,srt=90)

Again, we see that volcanic ashfall has a huge impact on property and crop damages. First frost also has a huge impact on both these factors.