This analysis tries to provide answers to two questions (across the US):
Which types of events are most harmful with respect to the population health?
Which types of events have the greatest economic consequences?
Based on the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database, we identified the top worst events across the US.
We based our study on the years 1996-2014 as the previous data was not clean enough.
We used the fatalities and injuries counts to select the health events.
We used the crop damage and property damage amounts to select the economic events.
These amounts have been adjusted for inflation and are in 2014 dollars.
We had to clean up the event types that were recorded on file as they were not very regular.
We focused on cleaning up the largest figures as there were orders of magnitude of difference between events.
The data is retrieved and unzipped.
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2","storm.csv.bz2", quiet=TRUE, method="curl")
Maybe we should trim spaces and set na.string=“NA”
storm.data<-read.table("storm.csv.bz2", header=TRUE, sep=",", quote="\"'", stringsAsFactors=FALSE)
There is a 115.0 Billion damage value in the database. We move to do this a 115.0 Million (looks more realistic based on the fact that “severe Weather causes $11 Billion in damages yearly according to this report.
storm.data[605953,]$PROPDMGEXP="M"
Let’s convert the dates and isolate the years that are after and including 1996. Data before that appears biased and contains errors as well.
require(lubridate) || install.packages("lubridate")
## [1] TRUE
storm.data2 <- storm.data
storm.data2$date <- as.POSIXct(strptime(storm.data2$BGN_DATE, "%m/%d/%Y %H:%M:%S"))
storm.data2$year <- year(storm.data2$date)
storm.subset <- storm.data2[storm.data2$year >= 1996, ]
entries <- length(storm.subset$year)
There are 653530 in the subset.
Let’s clean the EVTYPE field a bit as there are lowercase/upper case things in it, as well as leading/trailing blanks.
require(stringr) || install.packages("stringr")
## [1] TRUE
storm.subset$EVTYPE<-str_trim(toupper(storm.subset$EVTYPE))
Remove summary entries.
storm.subset<-storm.subset[!grepl("SUMMARY",storm.subset$EVTYPE),]
entries <- length(storm.subset$year)
There are 653454 in the subset now.
For health relevant data, we chose to pick events for which we had either fatalities or injuries.
storm.subset.health <- storm.subset[ (storm.subset$FATALITIES > 0) | (storm.subset$INJURIES > 0), ]
For economic relevant data, we chose to pick events for which we had crop damage or property damage.
storm.subset.economic <- storm.subset[(storm.subset$CROPDMG > 0) | (storm.subset$PROPDMG > 0), ]
The property and crop damage values have to be adjusted based on an “exponent” value that is held in the -EXP fields.
There is a complex rule for these and also weird entries.
unique(storm.data$PROPDMGEXP)
## [1] "K" "M" "" "B" "m" "+" "0" "5" "6" "?" "4" "2" "3" "h" "7" "H" "-"
## [18] "1" "8"
But on our subsetted data, things are easier, as there only remain a few.
unique(storm.subset.economic$PROPDMGEXP)
## [1] "K" "M" "" "B"
unique(storm.subset.economic$CROPDMGEXP)
## [1] "K" "" "M" "B"
The mapping we can use is the following:
| Prefix | Multiplier | Meaning |
|---|---|---|
| K | 1E3 | Thousands |
| M | 1E6 | Millions |
| B | 1E9 | Billions |
| blank | 1E0 -> 1 | Units |
We map the two subsets using that mapping.
mapping <- data.frame(
key = c("K", "M", "B", ""),
value = c(1E3, 1E6, 1E9, 1))
storm.subset.economic$PROPDMGEXP.converted <- sapply( storm.subset.economic$PROPDMGEXP, function(x){ mapping$value[match(x, mapping$key)] })
storm.subset.economic$CROPDMGEXP.converted <- sapply( storm.subset.economic$CROPDMGEXP, function(x){ mapping$value[match(x, mapping$key)] })
We can them compute the proper value:
storm.subset.economic$PROPDMG.value <- storm.subset.economic$PROPDMG * storm.subset.economic$PROPDMGEXP.converted
storm.subset.economic$CROPDMG.value <- storm.subset.economic$CROPDMG * storm.subset.economic$CROPDMGEXP.converted
We need to adjust the amounts for inflation.
We will load the figures for the consumer price index (CPI) and compute the yearly averaged CPI to adjust the amounts later.
The reference year is here is 2014. Adjustment factors are computed to convert amounts into 2014 dollars.
require(dplyr) || install.packages("dplyr")
## Loading required package: dplyr
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:lubridate':
##
## intersect, setdiff, union
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## [1] TRUE
monthly_cpi <- read.csv("http://research.stlouisfed.org/fred2/data/CPIAUCSL.csv", header = TRUE)
monthly_cpi$cpi_year <- year(monthly_cpi$DATE)
yearly_cpi <- monthly_cpi %>%
group_by(cpi_year) %>%
summarize(cpi = mean(VALUE))
yearly_cpi$adj_factor <- yearly_cpi$cpi/yearly_cpi$cpi[yearly_cpi$cpi_year == 2014]
Here are the values for the various years for 2014 dollars.
library(knitr)
kable(yearly_cpi, digits=2)
| cpi_year | cpi | adj_factor |
|---|---|---|
| 1947 | 22.33 | 0.09 |
| 1948 | 24.05 | 0.10 |
| 1949 | 23.81 | 0.10 |
| 1950 | 24.06 | 0.10 |
| 1951 | 25.97 | 0.11 |
| 1952 | 26.57 | 0.11 |
| 1953 | 26.77 | 0.11 |
| 1954 | 26.86 | 0.11 |
| 1955 | 26.80 | 0.11 |
| 1956 | 27.19 | 0.11 |
| 1957 | 28.11 | 0.12 |
| 1958 | 28.88 | 0.12 |
| 1959 | 29.15 | 0.12 |
| 1960 | 29.59 | 0.12 |
| 1961 | 29.90 | 0.13 |
| 1962 | 30.25 | 0.13 |
| 1963 | 30.63 | 0.13 |
| 1964 | 31.04 | 0.13 |
| 1965 | 31.53 | 0.13 |
| 1966 | 32.47 | 0.14 |
| 1967 | 33.38 | 0.14 |
| 1968 | 34.79 | 0.15 |
| 1969 | 36.68 | 0.15 |
| 1970 | 38.84 | 0.16 |
| 1971 | 40.48 | 0.17 |
| 1972 | 41.81 | 0.18 |
| 1973 | 44.42 | 0.19 |
| 1974 | 49.32 | 0.21 |
| 1975 | 53.83 | 0.23 |
| 1976 | 56.93 | 0.24 |
| 1977 | 60.62 | 0.26 |
| 1978 | 65.24 | 0.28 |
| 1979 | 72.58 | 0.31 |
| 1980 | 82.38 | 0.35 |
| 1981 | 90.93 | 0.38 |
| 1982 | 96.53 | 0.41 |
| 1983 | 99.58 | 0.42 |
| 1984 | 103.93 | 0.44 |
| 1985 | 107.60 | 0.45 |
| 1986 | 109.69 | 0.46 |
| 1987 | 113.62 | 0.48 |
| 1988 | 118.28 | 0.50 |
| 1989 | 123.94 | 0.52 |
| 1990 | 130.66 | 0.55 |
| 1991 | 136.17 | 0.58 |
| 1992 | 140.31 | 0.59 |
| 1993 | 144.47 | 0.61 |
| 1994 | 148.22 | 0.63 |
| 1995 | 152.38 | 0.64 |
| 1996 | 156.86 | 0.66 |
| 1997 | 160.53 | 0.68 |
| 1998 | 163.01 | 0.69 |
| 1999 | 166.58 | 0.70 |
| 2000 | 172.19 | 0.73 |
| 2001 | 177.04 | 0.75 |
| 2002 | 179.87 | 0.76 |
| 2003 | 184.00 | 0.78 |
| 2004 | 188.91 | 0.80 |
| 2005 | 195.27 | 0.82 |
| 2006 | 201.56 | 0.85 |
| 2007 | 207.34 | 0.88 |
| 2008 | 215.25 | 0.91 |
| 2009 | 214.56 | 0.91 |
| 2010 | 218.08 | 0.92 |
| 2011 | 224.93 | 0.95 |
| 2012 | 229.60 | 0.97 |
| 2013 | 232.96 | 0.98 |
| 2014 | 236.71 | 1.00 |
Then we need to ajust the amounts based on the adjustment factors.
How it works:
So, Price in 2014 dollars = Price Year x / adj_factor for the year
First, let’s assign the proper factor for each entry for the economic data.
storm.subset.economic.merged <-merge(storm.subset.economic, yearly_cpi, by.x="year", by.y="cpi_year")
We can now adjust the prices of the property damages and the crop damages.
storm.subset.economic.merged$PROPDMG.value.adjusted <- storm.subset.economic.merged$PROPDMG.value / storm.subset.economic.merged$adj_factor
storm.subset.economic.merged$CROPDMG.value.adjusted <- storm.subset.economic.merged$CROPDMG.value / storm.subset.economic.merged$adj_factor
The prices are now fine.
Let’s have a look on where we stand.
Summary for property damage ajusted values:
summary(storm.subset.economic.merged$PROPDMG.value.adjusted)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000e+00 3.018e+03 1.100e+04 1.599e+06 3.859e+04 3.794e+10
Summary for crop damage adjusted values:
summary(storm.subset.economic.merged$CROPDMG.value.adjusted)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000e+00 0.000e+00 0.000e+00 2.313e+05 0.000e+00 1.830e+09
As a reference point, let’s see how many fatalities and injuries we do have in total.
sum(storm.subset.health$FATALITIES)
## [1] 8732
sum(storm.subset.health$INJURIES)
## [1] 57975
We see that there are much more injuries than casualties.
First let’s aggregate things by event type to find out what the big groups do look like.
top <- 1:20
# Fatalities
fatalities.breakdown <- aggregate(storm.subset.health$FATALITIES, list(EventType=storm.subset.health$EVTYPE), FUN=sum)
names(fatalities.breakdown)<-c("EventType","Fatalities.Total")
fatalities.breakdown.ordered <- fatalities.breakdown[with(fatalities.breakdown, order(-Fatalities.Total)),]
# Injuries
injuries.breakdown <- aggregate(storm.subset.health$INJURIES, list(EventType=storm.subset.health$EVTYPE), FUN=sum)
names(injuries.breakdown)<-c("EventType","Injuries.Total")
injuries.breakdown.ordered <- injuries.breakdown[with(injuries.breakdown, order(-Injuries.Total)),]
# Property Damage
propdmg.breakdown <- aggregate(storm.subset.economic.merged$PROPDMG.value.adjusted, list(EventType=storm.subset.economic$EVTYPE), FUN=sum)
names(propdmg.breakdown)<-c("EventType","PropertyDamage.Total")
propdmg.breakdown.ordered <- propdmg.breakdown[with(propdmg.breakdown, order(-PropertyDamage.Total)),]
# Crop Damage
cropdmg.breakdown <- aggregate(storm.subset.economic.merged$CROPDMG.value.adjusted, list(EventType=storm.subset.economic$EVTYPE), FUN=sum)
names(cropdmg.breakdown)<-c("EventType","CropDamage.Total")
cropdmg.breakdown.ordered <- cropdmg.breakdown[
with(cropdmg.breakdown, order(-CropDamage.Total)),]
Basically, we get this set of event types for the 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 event types.
par(mar = c(5, 12, 4, 2))
par(mfrow=c(4,1))
barplot(fatalities.breakdown.ordered[top,]$Fatalities.Total,
names=fatalities.breakdown.ordered[top,]$EventType,
las=2, horiz=TRUE, border=NA, col=rainbow(length(top)),
xlab="Fatalities Count",
main="Top fatalities")
barplot(injuries.breakdown.ordered[top,]$Injuries.Total,
names=injuries.breakdown.ordered[top,]$EventType,
las=2, horiz=TRUE, border=NA, col=rainbow(length(top)),
xlab="Injuries Count",
main="Top injuries")
barplot(propdmg.breakdown.ordered[top,]$PropertyDamage.Total,
names=propdmg.breakdown.ordered[top,]$EventType,
las=2, horiz=TRUE, border=NA, col=rainbow(length(top)),
xlab="Total Amount ($)",
main="Top property damage")
plot.cropdmg <- barplot(cropdmg.breakdown.ordered[top,]$CropDamage.Total,
names=cropdmg.breakdown.ordered[top,]$EventType,
las=2, horiz=TRUE, border=NA, col=rainbow(length(top)),
xlab="Total Amount ($)",
main="Top crop damage")
We notice that the event types are not properly named in that top list. We need to put things together.
First of all, lets merge all top events and see what they are:
topevent.types <- unique(c(cropdmg.breakdown.ordered[top,1],propdmg.breakdown.ordered[top,1],injuries.breakdown.ordered[top,1],fatalities.breakdown.ordered[top,1]))
print(topevent.types)
## [1] "DROUGHT" "FLOOD"
## [3] "HAIL" "HURRICANE"
## [5] "HURRICANE/TYPHOON" "FLASH FLOOD"
## [7] "EXTREME COLD" "FROST/FREEZE"
## [9] "HEAVY RAIN" "TROPICAL STORM"
## [11] "HIGH WIND" "TSTM WIND"
## [13] "EXCESSIVE HEAT" "THUNDERSTORM WIND"
## [15] "TORNADO" "WILDFIRE"
## [17] "FREEZE" "WILD/FOREST FIRE"
## [19] "STRONG WIND" "HEAVY SNOW"
## [21] "STORM SURGE" "STORM SURGE/TIDE"
## [23] "ICE STORM" "WINTER STORM"
## [25] "LIGHTNING" "TYPHOON"
## [27] "HEAT" "FOG"
## [29] "BLIZZARD" "DUST STORM"
## [31] "WINTER WEATHER" "RIP CURRENT"
## [33] "AVALANCHE" "RIP CURRENTS"
## [35] "EXTREME COLD/WIND CHILL" "COLD/WIND CHILL"
## [37] "HIGH SURF"
We now have to have a conversion table to ratioanlize the event types in the original subsets.
replacements <- NULL
replacements <- rbind(replacements, data.frame(Pattern="HURRICANE/TYPHOON", Replacement="HURRICANE"))
replacements <- rbind(replacements, data.frame(Pattern=".*STORM SURGE.*", Replacement="STORM"))
replacements <- rbind(replacements, data.frame(Pattern=".*RIP CURRENT.*", Replacement="RIP CURRENT"))
replacements <- rbind(replacements, data.frame(Pattern=".*WINTER.*", Replacement="COLD"))
replacements <- rbind(replacements, data.frame(Pattern=".*BLIZZARD.*", Replacement="COLD"))
replacements <- rbind(replacements, data.frame(Pattern=".*FLOOD.*", Replacement="FLOOD"))
replacements <- rbind(replacements, data.frame(Pattern=".*COLD.*", Replacement="COLD"))
replacements <- rbind(replacements, data.frame(Pattern=".*FROST.*", Replacement="COLD"))
replacements <- rbind(replacements, data.frame(Pattern="TYPHOON", Replacement="HURRICANE"))
replacements <- rbind(replacements, data.frame(Pattern=".*WILD/FOREST FIRE.*", Replacement="WILDFIRE"))
replacements <- rbind(replacements, data.frame(Pattern=".*ICE.*", Replacement="COLD"))
replacements <- rbind(replacements, data.frame(Pattern=".*STORM.*", Replacement="STORM"))
replacements <- rbind(replacements, data.frame(Pattern=".*TSTM WIND.*", Replacement="THUNDERSTORM WIND"))
replacements <- rbind(replacements, data.frame(Pattern=".*HURRICANE.*", Replacement="HURRICANE"))
Let’s replace.
for (i in 1:nrow(replacements)) {
row <- replacements[i,]
print(paste("pattern:", row$Pattern, "replacement:",row$Replacement))
storm.subset.economic.merged$EVTYPE[grepl(as.character(row$Pattern), storm.subset.economic.merged$EVTYPE)] <- as.character(row$Replacement)
storm.subset.health$EVTYPE[grepl(as.character(row$Pattern), storm.subset.health$EVTYPE)] <- as.character(row$Replacement)
}
## [1] "pattern: HURRICANE/TYPHOON replacement: HURRICANE"
## [1] "pattern: .*STORM SURGE.* replacement: STORM"
## [1] "pattern: .*RIP CURRENT.* replacement: RIP CURRENT"
## [1] "pattern: .*WINTER.* replacement: COLD"
## [1] "pattern: .*BLIZZARD.* replacement: COLD"
## [1] "pattern: .*FLOOD.* replacement: FLOOD"
## [1] "pattern: .*COLD.* replacement: COLD"
## [1] "pattern: .*FROST.* replacement: COLD"
## [1] "pattern: TYPHOON replacement: HURRICANE"
## [1] "pattern: .*WILD/FOREST FIRE.* replacement: WILDFIRE"
## [1] "pattern: .*ICE.* replacement: COLD"
## [1] "pattern: .*STORM.* replacement: STORM"
## [1] "pattern: .*TSTM WIND.* replacement: THUNDERSTORM WIND"
## [1] "pattern: .*HURRICANE.* replacement: HURRICANE"
# Let's update the levels to get rid of the old ones.
levels(storm.subset.health$EVTYPE) <- unique(storm.subset.health$EVTYPE)
levels(storm.subset.economic.merged$EVTYPE) <- unique(storm.subset.economic.merged$EVTYPE)
See if we replaced properly…
unique(storm.subset.health$EVTYPE)
## [1] "TORNADO" "FLOOD"
## [3] "COLD" "THUNDERSTORM WIND"
## [5] "LIGHTNING" "EXCESSIVE HEAT"
## [7] "RIP CURRENT" "HEAVY SNOW"
## [9] "STORM" "URBAN/SML STREAM FLD"
## [11] "FOG" "ROUGH SURF"
## [13] "WILDFIRE" "HIGH WIND"
## [15] "DUST DEVIL" "HEAVY RAIN"
## [17] "MARINE ACCIDENT" "HEAVY SURF"
## [19] "AVALANCHE" "DRY MICROBURST"
## [21] "HAIL" "WINDS"
## [23] "HURRICANE" "HIGH SURF"
## [25] "TORRENTIAL RAINFALL" "STRONG WINDS"
## [27] "EXTREME WINDCHILL" "WHIRLWIND"
## [29] "HEAVY SNOW SHOWER" "MIXED PRECIP"
## [31] "FREEZING SPRAY" "MUDSLIDES"
## [33] "MUDSLIDE" "STRONG WIND"
## [35] "SNOW" "HEAT WAVE"
## [37] "RAIN/SNOW" "WIND"
## [39] "HEAT" "SNOW SQUALL"
## [41] "ICY ROADS" "HYPOTHERMIA/EXPOSURE"
## [43] "GUSTY WINDS" "WATERSPOUT"
## [45] "BLOWING SNOW" "FREEZING DRIZZLE"
## [47] "SNOW SQUALLS" "HEAVY SURF AND WIND"
## [49] "LANDSLIDES" "HIGH SWELLS"
## [51] "SMALL HAIL" "GLAZE"
## [53] "FREEZING RAIN" "HYPERTHERMIA/EXPOSURE"
## [55] "WINTRY MIX" "FUNNEL CLOUD"
## [57] "GUSTY WIND" "HEAVY SEAS"
## [59] "UNSEASONABLY WARM" "RECORD HEAT"
## [61] "EXCESSIVE SNOW" "HIGH SEAS"
## [63] "ROUGH SEAS" "NON-SEVERE WIND DAMAGE"
## [65] "WARM WEATHER" "HIGH WATER"
## [67] "LIGHT SNOW" "ROGUE WAVE"
## [69] "OTHER" "BRUSH FIRE"
## [71] "HAZARDOUS SURF" "DROWNING"
## [73] "DENSE FOG" "LANDSLIDE"
## [75] "HEAVY SURF/HIGH SURF" "DROUGHT"
## [77] "MARINE STRONG WIND" "MARINE HIGH WIND"
## [79] "TSUNAMI"
unique(storm.subset.economic.merged$EVTYPE)
## [1] "COLD" "TORNADO"
## [3] "THUNDERSTORM WIND" "HIGH WIND"
## [5] "FLOOD" "FREEZING RAIN"
## [7] "LIGHTNING" "HAIL"
## [9] "OTHER" "HEAVY SNOW"
## [11] "WILDFIRE" "STORM"
## [13] "STRONG WIND" "DUST DEVIL"
## [15] "URBAN/SML STREAM FLD" "ROUGH SURF"
## [17] "HEAVY SURF" "HEAVY RAIN"
## [19] "MARINE ACCIDENT" "FREEZE"
## [21] "DRY MICROBURST" "FOG"
## [23] "WATERSPOUT" "DAMAGING FREEZE"
## [25] "BEACH EROSION" "HIGH SURF"
## [27] "HEAVY RAIN/HIGH SURF" "WINTRY MIX"
## [29] "DROUGHT" "LANDSLUMP"
## [31] "HURRICANE" "EXTREME WINDCHILL"
## [33] "GLAZE" "WHIRLWIND"
## [35] "HEAVY SNOW SHOWER" "LIGHT SNOW"
## [37] "DOWNBURST" "MICROBURST"
## [39] "SNOW" "SNOW SQUALLS"
## [41] "WIND DAMAGE" "LIGHT SNOWFALL"
## [43] "FREEZING DRIZZLE" "GUSTY WIND/RAIN"
## [45] "GUSTY WIND/HVY RAIN" "WIND"
## [47] "STRONG WINDS" "GUSTY WINDS"
## [49] "GUSTY WIND" "HARD FREEZE"
## [51] "MUD SLIDE" "EXCESSIVE HEAT"
## [53] "AGRICULTURAL FREEZE" "SNOW SQUALL"
## [55] "ICY ROADS" "LAKE EFFECT SNOW"
## [57] "MIXED PRECIPITATION" "DAM BREAK"
## [59] "BLOWING SNOW" "GRADIENT WIND"
## [61] "WET MICROBURST" "FUNNEL CLOUD"
## [63] "LANDSLIDES" "HIGH SWELLS"
## [65] "HIGH WINDS" "SMALL HAIL"
## [67] "UNSEASONAL RAIN" "AVALANCHE"
## [69] "HIGH WIND (G40)" "COASTAL EROSION"
## [71] "UNSEASONABLY WARM" "SEICHE"
## [73] "ROCK SLIDE" "GUSTY WIND/HAIL"
## [75] "LANDSPOUT" "EXCESSIVE SNOW"
## [77] "WIND AND WAVE" "LIGHT FREEZING RAIN"
## [79] "HIGH SEAS" "RIP CURRENT"
## [81] "RAIN" "NON-SEVERE WIND DAMAGE"
## [83] "LANDSLIDE" "LATE SEASON SNOW"
## [85] "MUDSLIDE" "BLOWING DUST"
## [87] "VOLCANIC ASH" "HIGH SURF ADVISORY"
## [89] "DENSE FOG" "ASTRONOMICAL HIGH TIDE"
## [91] "HEAVY SURF/HIGH SURF" "TROPICAL DEPRESSION"
## [93] "LAKE-EFFECT SNOW" "MARINE HIGH WIND"
## [95] "TSUNAMI" "HEAT"
## [97] "MARINE STRONG WIND" "ASTRONOMICAL LOW TIDE"
## [99] "DENSE SMOKE" "MARINE HAIL"
## [101] "FREEZING FOG"
We can now recompute based on the replaced values.
remove(fatalities.breakdown)
remove(fatalities.breakdown.ordered)
remove(injuries.breakdown)
remove(injuries.breakdown.ordered)
remove(propdmg.breakdown)
remove(propdmg.breakdown.ordered)
remove(cropdmg.breakdown)
remove(cropdmg.breakdown.ordered)
# Fatalities
fatalities.breakdown <- aggregate(storm.subset.health$FATALITIES, list(EventType=storm.subset.health$EVTYPE), FUN=sum)
names(fatalities.breakdown)<-c("EventType","Fatalities.Total")
fatalities.breakdown.ordered <- fatalities.breakdown[with(fatalities.breakdown, order(-Fatalities.Total)),]
# Injuries
injuries.breakdown <- aggregate(storm.subset.health$INJURIES, list(EventType=storm.subset.health$EVTYPE), FUN=sum)
names(injuries.breakdown)<-c("EventType","Injuries.Total")
injuries.breakdown.ordered <- injuries.breakdown[with(injuries.breakdown, order(-Injuries.Total)),]
# Property Damage
propdmg.breakdown <- aggregate(storm.subset.economic.merged$PROPDMG.value.adjusted, list(EventType=storm.subset.economic$EVTYPE), FUN=sum)
names(propdmg.breakdown)<-c("EventType","PropertyDamage.Total")
propdmg.breakdown.ordered <- propdmg.breakdown[with(propdmg.breakdown, order(-PropertyDamage.Total)),]
# Crop Damage
cropdmg.breakdown <- aggregate(storm.subset.economic.merged$CROPDMG.value.adjusted, list(EventType=storm.subset.economic$EVTYPE), FUN=sum)
names(cropdmg.breakdown)<-c("EventType","CropDamage.Total")
cropdmg.breakdown.ordered <- cropdmg.breakdown[
with(cropdmg.breakdown, order(-CropDamage.Total)),]
and plot again.
par(mar = c(5, 12, 4, 2))
par(mfrow=c(4,1))
barplot(fatalities.breakdown.ordered[top,]$Fatalities.Total,
names=fatalities.breakdown.ordered[top,]$EventType,
las=2, horiz=TRUE, border=NA, col=rainbow(length(top)),
xlab="Fatalities Count",
main="Top fatalities")
barplot(injuries.breakdown.ordered[top,]$Injuries.Total,
names=injuries.breakdown.ordered[top,]$EventType,
las=2, horiz=TRUE, border=NA, col=rainbow(length(top)),
xlab="Injuries Count",
main="Top injuries")
barplot(propdmg.breakdown.ordered[top,]$PropertyDamage.Total,
names=propdmg.breakdown.ordered[top,]$EventType,
las=2, horiz=TRUE, border=NA, col=rainbow(length(top)),
xlab="Total Amount ($)",
main="Top property damage")
plot.cropdmg <- barplot(cropdmg.breakdown.ordered[top,]$CropDamage.Total,
names=cropdmg.breakdown.ordered[top,]$EventType,
las=2, horiz=TRUE, border=NA, col=rainbow(length(top)),
xlab="Total Amount ($)",
main="Top crop damage")
Based on our analysis, the results are presented below:
The most harmful types of events with respect to the population health are (in descending order)
| For Fatalities | For Injuries |
|---|---|
| Heat | Tornadoes |
| Tornadoes | Floods |
| Floods | Heat |
The events with the greatest economic consequences are (in descending order)
| For Property | For Crops |
|---|---|
| Hurricanes | Drought |
| Storms | Floods |
| Floods | Hurricanes |
No support sections