This analysis explores the U.S. National Oceanic and Atmospheric Administration (NOAA) storm database from 1950 to November 2011. The database tracks characteristics of major storms and weather events including fatalities, injuries, property damage, and crop damage. This analysis addresses two questions: which types of events are most harmful to population health, and which types have the greatest economic consequences.
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2",
destfile="StormData.csv.bz2")
storm <- read.csv("StormData.csv.bz2")
fatalities_by_event <- aggregate(FATALITIES ~ EVTYPE, data=storm, FUN=sum)
injuries_by_event <- aggregate(INJURIES ~ EVTYPE, data=storm, FUN=sum)
top_fatalities <- head(fatalities_by_event[order(-fatalities_by_event$FATALITIES),], 10)
top_injuries <- head(injuries_by_event[order(-injuries_by_event$INJURIES),], 10)
par(mfrow=c(1,2))
barplot(top_fatalities$FATALITIES,
names.arg=top_fatalities$EVTYPE,
xlab="Event Type",
ylab="Number of Fatalities",
main="Top 10 by Fatalities",
las=2)
barplot(top_injuries$INJURIES,
names.arg=top_injuries$EVTYPE,
xlab="Event Type",
ylab="Number of Injuries",
main="Top 10 by Injuries",
las=2)
Figure 1: The plots show the top 10 weather events by fatalities (left)
and injuries (right)in the US from 1950-2011. Tornadoes are the most
harmful event for both measures.
property_damage <- aggregate(PROPDMG ~ EVTYPE, data=storm, FUN=sum)
crop_damage <- aggregate(CROPDMG ~ EVTYPE, data=storm, FUN=sum)
top_PROPDMG <- head(property_damage[order(-property_damage$PROPDMG),], 10)
top_CROPDMG <- head(crop_damage[order(-crop_damage$CROPDMG),], 10)
barplot(top_PROPDMG$PROPDMG,
names.arg=top_PROPDMG$EVTYPE,
xlab="Event Type",
ylab="Number of Property Damage",
main="Top 10 Weather Events by Property Damage",
las=2)
Figure 2: Top 10 weather events by property damage. Tornadoes cause the
most property damage.
barplot(top_CROPDMG$CROPDMG,
names.arg=top_CROPDMG$EVTYPE,
xlab="Event Type",
ylab="Number of Crop Damage",
main="Top 10 Weather Events by Crop Damage",
las=2)
Figure 3: Top 10 weather events by crop damage. Hail causes the most
crop damage.