This report explores the weather events that have had the greatest impact on people’s health and economies in the United States. The data used is available from NOAA, which spans April 1950 – November 2011. Earlier data in this dataset is less complete, but it is included here because even incomplete data when measuring a cumulative, historical impact can be important.
It is noteworthy that while the instructions to storm data preparers (http://www.ncdc.noaa.gov/stormevents/pd01016005curr.pdf) specify 48 permitted event types, 985 different types are seen throughout the data. The reported values are used for this analysis.
The data has been downloaded from the Coursera website. Two subsets are created: one to examine which types of events are most harmful with respect to population health and another to look at which type of events have the greatest economic consequences.
library(dplyr)
setwd("~/Desktop/Coursera/NOAA")
download.file("http://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2", "repdata-data-StormData.csv.bz2")
storm <- read.csv("repdata-data-StormData.csv.bz2")
## Create the subset to look at impact to population health
stormCasualty <- subset(storm, select = c(EVTYPE, FATALITIES, INJURIES))
## Create the subset to look at economic consequences
stormEcon <- subset(storm, select = c(EVTYPE, PROPDMG, PROPDMGEXP, CROPDMG, CROPDMGEXP))
## Create lookup tables for the magnitude of the damage amounts.
## The documentation states that "estimates should be rounded to three significant digits, followed by
## an alphabetical character signifying the magnitude of the number, i.e., 1.55B for $1,550,000,000.
## Alphabetical characters used to signify magnitude include “K” for thousands, “M” for millions, and “B” for
## billions."
## One is used as the multiplier for all non-alphabetic indicators.
propExp <- distinct(select(stormEcon, PROPDMGEXP))
propExp$propMult <- c(1000, 1000000, 1, 1000000000, 1000000, 1, 1, 1, 1, 1, 1, 1, 1, 100, 1, 100, 1, 1, 1)
stormEcon <- merge(stormEcon, propExp, all.x=TRUE)
cropExp <- distinct(select(stormEcon, CROPDMGEXP))
cropExp$cropMult <- c(1, 1000, 1000000, 1000000000, 1, 1, 1, 1000, 1000000)
stormEcon <- merge(stormEcon, cropExp, all.x=TRUE)
## Adding columns to display the calculated damage amounts
stormEcon$propertyDamage <- stormEcon$PROPDMG * stormEcon$propMult
stormEcon$cropDamage <- stormEcon$CROPDMG * stormEcon$cropMult
Across the United States, which types of events are most harmful with respect to population health?
Deaths and Injuries are totaled across time and place by event type. A total of all incidents is also calculated. An examination of the data shows the most deaths resulting from a single event type is 5633, while the greatest number of injuries resulting from a single event type is 91,346.
A threshold of 100 is set for deaths and 1000 for injuries to get the events with the greatest impact to health. Since death is a more significant occurence than injury, the resulting data is arranged by the number of deaths for each event type in the U.S.
library(dplyr)
##
## Attaching package: 'dplyr'
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(lattice)
options(scipen=10)
deaths <- stormCasualty %>%
group_by(EVTYPE) %>%
summarise(AllDeaths = sum(FATALITIES))
injuries <- stormCasualty %>%
group_by(EVTYPE) %>%
summarise(AllHurt = sum(INJURIES))
# max(deaths$AllDeaths) ## 5633
# max(injuries$AllHurt) ## 91346
mostDeaths <- subset(deaths, AllDeaths > 100)
mostInjuries <- subset(injuries, AllHurt > 1000)
mostCasualties <- merge (mostDeaths, mostInjuries, all=TRUE)
## If either Deaths or Injuries by event type are NA, the total incident column will be NA
mostCasualties$allIncidents <- 0
for (i in 1:nrow(mostCasualties)) {
dead <- 0
hurt <- 0
if (is.na(mostCasualties[i,2])) {
mostCasualties[i,4] <- NA
}
else {
dead <- mostCasualties[i,2]
if (is.na(mostCasualties[i,3])) {
mostCasualties[i,4] <- NA
}
else {
hurt <- mostCasualties[i,3]
}
}
if (!is.na(mostCasualties[i,4])) {
mostCasualties[i,4] <- dead + hurt
}
}
colnames(mostCasualties) <- c("WeatherEvent","Deaths","Injuries","AllIncidents")
arrange(mostCasualties,desc(Deaths))
## WeatherEvent Deaths Injuries AllIncidents
## 1 TORNADO 5633 91346 96979
## 2 EXCESSIVE HEAT 1903 6525 8428
## 3 FLASH FLOOD 978 1777 2755
## 4 HEAT 937 2100 3037
## 5 LIGHTNING 816 5230 6046
## 6 TSTM WIND 504 6957 7461
## 7 FLOOD 470 6789 7259
## 8 RIP CURRENT 368 NA NA
## 9 HIGH WIND 248 1137 1385
## 10 AVALANCHE 224 NA NA
## 11 WINTER STORM 206 1321 1527
## 12 RIP CURRENTS 204 NA NA
## 13 HEAT WAVE 172 NA NA
## 14 EXTREME COLD 160 NA NA
## 15 THUNDERSTORM WIND 133 1488 1621
## 16 HEAVY SNOW 127 1021 1148
## 17 EXTREME COLD/WIND CHILL 125 NA NA
## 18 STRONG WIND 103 NA NA
## 19 BLIZZARD 101 NA NA
## 20 HIGH SURF 101 NA NA
## 21 HAIL NA 1361 NA
## 22 HURRICANE/TYPHOON NA 1275 NA
## 23 ICE STORM NA 1975 NA
top10 <- (arrange(mostCasualties,desc(Deaths)))[1:10,]
barchart(Deaths+Injuries~WeatherEvent,data=top10, scales=list(x=list(rot=90)), main = "Top 10 Weather Events for U.S. Death 1950-2011", ylab="Number of Deaths (blue) and Injuries (pink)")
Across the United States, which types of events have the greatest economic consequences?
Property damage and crop damage are totaled by event type. The summarized datasets are merged and a total damage amount is calculated by summing crop damage totals and property damage totals for each event type. The 50 event types that have resulted in the greatest costs recorded are selected.
library(lattice)
property <- stormEcon %>%
group_by(EVTYPE) %>%
summarise(PropertyTotal = sum(propertyDamage))
crop <- stormEcon %>%
group_by(EVTYPE) %>%
summarise(CropTotal = sum(cropDamage))
econImpact <- merge(crop, property, all=TRUE)
econImpact$AllDamage <- econImpact$CropTotal + econImpact$PropertyTotal
mostDamage <- arrange(econImpact,desc(AllDamage))
colnames(mostDamage) <- c("WeatherEvent","CropDamage","PropertyDamage","TotalDamage")
arrange(mostDamage[1:50,], desc(TotalDamage))
## WeatherEvent CropDamage PropertyDamage TotalDamage
## 1 FLOOD 5661968450 144657709807 150319678257
## 2 HURRICANE/TYPHOON 2607872800 69305840000 71913712800
## 3 TORNADO 414953270 56937160779 57352114049
## 4 STORM SURGE 5000 43323536000 43323541000
## 5 HAIL 3025954473 15732267543 18758222016
## 6 FLASH FLOOD 1421317100 16140812067 17562129167
## 7 DROUGHT 13972566000 1046106000 15018672000
## 8 HURRICANE 2741910000 11868319010 14610229010
## 9 RIVER FLOOD 5029459000 5118945500 10148404500
## 10 ICE STORM 5022113500 3944927860 8967041360
## 11 TROPICAL STORM 678346000 7703890550 8382236550
## 12 WINTER STORM 26944000 6688497251 6715441251
## 13 HIGH WIND 638571300 5270046295 5908617595
## 14 WILDFIRE 295472800 4765114000 5060586800
## 15 TSTM WIND 554007350 4484928495 5038935845
## 16 STORM SURGE/TIDE 850000 4641188000 4642038000
## 17 THUNDERSTORM WIND 414843050 3483121284 3897964334
## 18 HURRICANE OPAL 19000000 3172846000 3191846000
## 19 WILD/FOREST FIRE 106796830 3001829500 3108626330
## 20 HEAVY RAIN/SEVERE WEATHER 0 2500000000 2500000000
## 21 THUNDERSTORM WINDS 190654788 1735961003 1926615791
## 22 TORNADOES, TSTM WIND, HAIL 2500000 1600000000 1602500000
## 23 HEAVY RAIN 733399800 694248090 1427647890
## 24 EXTREME COLD 1292973000 67737400 1360710400
## 25 SEVERE THUNDERSTORM 200000 1205360000 1205560000
## 26 FROST/FREEZE 1094086000 9480000 1103566000
## 27 HEAVY SNOW 134653100 932589142 1067242242
## 28 LIGHTNING 12092090 928659447 940751537
## 29 BLIZZARD 112060000 659213950 771273950
## 30 HIGH WINDS 40720600 608323748 649044348
## 31 WILD FIRES 0 624100000 624100000
## 32 TYPHOON 825000 600230000 601055000
## 33 EXCESSIVE HEAT 492402000 7753700 500155700
## 34 FREEZE 446225000 205000 446430000
## 35 HEAT 401461500 1797000 403258500
## 36 HURRICANE ERIN 136010000 258100000 394110000
## 37 LANDSLIDE 20017000 324596000 344613000
## 38 FLASH FLOODING 15116050 307763604 322879654
## 39 FLASH FLOOD/FLOOD 555000 272450006 273005006
## 40 DAMAGING FREEZE 262100000 8000000 270100000
## 41 FLOOD/FLASH FLOOD 95034000 174039009 269073009
## 42 HAILSTORM 0 241000000 241000000
## 43 STRONG WIND 64953500 175241450 240194950
## 44 COASTAL FLOOD 0 237665560 237665560
## 45 TSUNAMI 20000 144062000 144082000
## 46 EXCESSIVE WETNESS 142000000 0 142000000
## 47 River Flooding 28020000 106155000 134175000
## 48 COASTAL FLOODING 56000 126640500 126696500
## 49 HIGH WINDS/COLD 7000000 110500000 117500000
## 50 FLOODING 8855500 108255006 117110506
top10 <- mostDamage[1:10,]
barchart(TotalDamage~WeatherEvent,data=top10, scales=list(x=list(rot=90)), main="Top 10 Weather Events for U.S. Economic Impact 1950-2011", ylab="Cost in Dollars (Crop and Property Damage)")