The US National Oceanic and Atmospheric Administration’s (NOAA) storm database tracks weather events—where and when they occur, and the resulting damage in terms of human health and property. Our task is to take the data from this database, spanning the years from 1950 to 2011, and determine which types of events are the most injurious to health and property. First, the database is read in as a data frame and parts of the data that are relevant to our analysis are selected. Then, the data is cleaned by combining some event categories that likely refer to single categories. Finally, the data is summarized by event type to tally fatalities, injuries, and property and crop damage.
The raw data comes in the form of a compressed CSV (extension “.csv.bz2”). It can be read directly, uncompressed, using read.csv, but I chose to use fread from the data.table package, which decompresses first. It ends up being faster and more reliable on slow systems.
packages<-c("data.table", "R.utils", "dplyr", "ggplot2", "ggpubr")
install.packages(setdiff(packages, rownames(installed.packages())))
library(data.table)
library(R.utils)
storm<-fread("repdata_data_StormData.csv.bz2")
The result is a data frame with almost 1 million rows and 37 columns–that’s a huge data set! How do we pare that down to what we need?
First, when trying to figure out which types of weather events have the most impact to human health, we’ll need to focus on injuries, fatalities, and property or crop damage. We’ll remove all events that have either 0 fatalities, 0 injuries, 0 property damage, or 0 crop damage.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
stormdata<-storm%>%select(BGN_DATE, END_DATE, TIME_ZONE, EVTYPE, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP, CROPDMG, CROPDMGEXP)%>%filter(FATALITIES != 0 | INJURIES != 0 | PROPDMG != 0 | CROPDMG != 0)
Secondly, according to the NOAA website (here), while the data started being collected in 1950, the only event type for which information was collected initially was tornado, thunderstorm wind, and hail. It’s only in January 1996 that all event types started to be recorded. It would potentially skew our results if we left dates from 1950 to 1996 in, so we’ll take those out.
stormdata$BGN_DATE<-as.Date(stormdata$BGN_DATE, format = "%m/%d/%Y %H:%M:%S")
stormdata<-stormdata%>%subset(BGN_DATE > "1996-01-01")
Next, looking at the names of the categories of weather events, you can see there are some obvious repeats. There are also a few that are a little more questionable.
str<-unique(stormdata$EVTYPE)
d<-adist(str)
rownames(d)<-str
hc<-hclust(as.dist(d))
df<-data.frame(str, cluster = cutree(hc, k = 50))
df<-df%>%filter(cluster != 1)%>%arrange(cluster)
print(df)
## str cluster
## TORNADO TORNADO 2
## HIGH WIND HIGH WIND 2
## LIGHTNING LIGHTNING 2
## HAIL HAIL 2
## FLOOD FLOOD 2
## Other Other 2
## HEAVY SNOW HEAVY SNOW 2
## BLIZZARD BLIZZARD 2
## DUST DEVIL DUST DEVIL 2
## FOG FOG 2
## ROUGH SURF ROUGH SURF 2
## Heavy Surf Heavy Surf 2
## Dust Devil Dust Devil 2
## HEAVY RAIN HEAVY RAIN 2
## Freeze Freeze 2
## WINDS WINDS 2
## WATERSPOUT WATERSPOUT 2
## HURRICANE HURRICANE 2
## High Surf High Surf 2
## Early Frost Early Frost 2
## Wintry Mix Wintry Mix 2
## DROUGHT DROUGHT 2
## Landslump Landslump 2
## Glaze Glaze 2
## COLD COLD 2
## DOWNBURST DOWNBURST 2
## Mudslides Mudslides 2
## Microburst Microburst 2
## Mudslide Mudslide 2
## Cold Cold 2
## SNOW SNOW 2
## Snow Squalls Snow Squalls 2
## Wind Damage Wind Damage 2
## Wind Wind 2
## Heat Wave Heat Wave 2
## Snow Snow 2
## HEAVY SURF HEAVY SURF 2
## RAIN/SNOW RAIN/SNOW 2
## WIND WIND 2
## FREEZE FREEZE 2
## HEAT HEAT 2
## HIGH SURF HIGH SURF 2
## MUD SLIDE MUD SLIDE 2
## SNOW AND ICE SNOW AND ICE 2
## SNOW SQUALL SNOW SQUALL 2
## ICY ROADS ICY ROADS 2
## OTHER OTHER 2
## BLACK ICE BLACK ICE 2
## LIGHT SNOW LIGHT SNOW 2
## DAM BREAK DAM BREAK 2
## FROST FROST 2
## TYPHOON TYPHOON 2
## LANDSLIDES LANDSLIDES 2
## HIGH SWELLS HIGH SWELLS 2
## HIGH WINDS HIGH WINDS 2
## SMALL HAIL SMALL HAIL 2
## GLAZE GLAZE 2
## SEICHE SEICHE 2
## WINTRY MIX WINTRY MIX 2
## ROCK SLIDE ROCK SLIDE 2
## HEAVY SEAS HEAVY SEAS 2
## LANDSPOUT LANDSPOUT 2
## ICE ROADS ICE ROADS 2
## HIGH SEAS HIGH SEAS 2
## RAIN RAIN 2
## ROUGH SEAS ROUGH SEAS 2
## LANDSLIDE LANDSLIDE 2
## HIGH WATER HIGH WATER 2
## ROGUE WAVE ROGUE WAVE 2
## MUDSLIDE MUDSLIDE 2
## BRUSH FIRE BRUSH FIRE 2
## WILDFIRE WILDFIRE 2
## WHIRLWIND WHIRLWIND 2
## ICE ON ROAD ICE ON ROAD 2
## SNOW SQUALLS SNOW SQUALLS 2
## DROWNING DROWNING 2
## DENSE FOG DENSE FOG 2
## TSUNAMI TSUNAMI 2
## DENSE SMOKE DENSE SMOKE 2
## MARINE HAIL MARINE HAIL 2
## TSTM WIND TSTM WIND 3
## EXTREME COLD EXTREME COLD 3
## STRONG WIND STRONG WIND 3
## TIDAL FLOODING TIDAL FLOODING 3
## GUSTY WIND GUSTY WIND 3
## RIVER FLOOD RIVER FLOOD 3
## STRONG WINDS STRONG WINDS 3
## GRADIENT WIND GRADIENT WIND 3
## GUSTY WINDS GUSTY WINDS 3
## FUNNEL CLOUD FUNNEL CLOUD 3
## RIVER FLOODING RIVER FLOODING 3
## TSTM WIND TSTM WIND 3
## NON-TSTM WIND NON-TSTM WIND 3
## NON TSTM WIND NON TSTM WIND 3
## FLASH FLOOD FLASH FLOOD 4
## FLOOD/FLASH/FLOOD FLOOD/FLASH/FLOOD 4
## FLASH FLOOD/FLOOD FLASH FLOOD/FLOOD 4
## FLASH FLOOD FLASH FLOOD 4
## LAKESHORE FLOOD LAKESHORE FLOOD 4
## FREEZING RAIN FREEZING RAIN 5
## FREEZING DRIZZLE FREEZING DRIZZLE 5
## FALLING SNOW/ICE FALLING SNOW/ICE 5
## FREEZING FOG FREEZING FOG 5
## TSTM WIND/HAIL TSTM WIND/HAIL 6
## GUSTY WIND/HVY RAIN GUSTY WIND/HVY RAIN 6
## GUSTY WIND/HAIL GUSTY WIND/HAIL 6
## EXCESSIVE HEAT EXCESSIVE HEAT 7
## EXCESSIVE SNOW EXCESSIVE SNOW 7
## RIP CURRENTS RIP CURRENTS 8
## COLD AND SNOW COLD AND SNOW 8
## RIP CURRENT RIP CURRENT 8
## RECORD HEAT RECORD HEAT 8
## WIND AND WAVE WIND AND WAVE 8
## WILD/FOREST FIRE WILD/FOREST FIRE 9
## HAZARDOUS SURF HAZARDOUS SURF 9
## STORM SURGE STORM SURGE 10
## STORM SURGE/TIDE STORM SURGE/TIDE 10
## Ice jam flood (minor Ice jam flood (minor 11
## Tstm Wind Tstm Wind 12
## Strong Wind Strong Wind 12
## Strong Winds Strong Winds 12
## Whirlwind Whirlwind 12
## Gusty Winds Gusty Winds 12
## Gusty winds Gusty winds 12
## blowing snow blowing snow 12
## gradient wind gradient wind 12
## Gradient wind Gradient wind 12
## URBAN/SML STREAM FLD URBAN/SML STREAM FLD 13
## Marine Accident Marine Accident 14
## DRY MICROBURST DRY MICROBURST 15
## WET MICROBURST WET MICROBURST 15
## BLOWING DUST BLOWING DUST 15
## Erosion/Cstl Flood Erosion/Cstl Flood 16
## River Flooding River Flooding 17
## Beach Erosion Beach Erosion 17
## Tidal Flooding Tidal Flooding 17
## Light snow Light snow 17
## Light Snow Light Snow 17
## Light Snowfall Light Snowfall 17
## DAMAGING FREEZE DAMAGING FREEZE 18
## HARD FREEZE HARD FREEZE 18
## AGRICULTURAL FREEZE AGRICULTURAL FREEZE 18
## FROST/FREEZE FROST/FREEZE 18
## Damaging Freeze Damaging Freeze 19
## Frost/Freeze Frost/Freeze 19
## Heavy Rain/High Surf Heavy Rain/High Surf 20
## Unseasonable Cold Unseasonable Cold 21
## Extreme Cold Extreme Cold 21
## Extended Cold Extended Cold 21
## Coastal Flooding Coastal Flooding 22
## Coastal Storm Coastal Storm 22
## Coastal Flood Coastal Flood 22
## Torrential Rainfall Torrential Rainfall 23
## Hurricane Edouard Hurricane Edouard 24
## EXTREME WINDCHILL EXTREME WINDCHILL 25
## EXTREME COLD/WIND CHILL EXTREME COLD/WIND CHILL 25
## COLD/WIND CHILL COLD/WIND CHILL 25
## Heavy snow shower Heavy snow shower 26
## Heavy surf and wind Heavy surf and wind 26
## COASTAL FLOOD COASTAL FLOOD 27
## COASTAL FLOODING COASTAL FLOODING 27
## COASTAL EROSION COASTAL EROSION 27
## MIXED PRECIP MIXED PRECIP 28
## MIXED PRECIPITATION MIXED PRECIPITATION 28
## Freezing Spray Freezing Spray 29
## Freezing Drizzle Freezing Drizzle 29
## Freezing Rain Freezing Rain 29
## Freezing drizzle Freezing drizzle 29
## Gusty wind/rain Gusty wind/rain 30
## Cold Temperature Cold Temperature 31
## TSTM WIND (G45) TSTM WIND (G45) 32
## TSTM WIND 40 TSTM WIND 40 32
## TSTM WIND 45 TSTM WIND 45 32
## TSTM WIND (41) TSTM WIND (41) 32
## TSTM WIND (G40) TSTM WIND (G40) 32
## TSTM WIND (G45) TSTM WIND (G45) 32
## TSTM WIND (G45) TSTM WIND (G45) 32
## HIGH WIND (G40) HIGH WIND (G40) 32
## TSTM WIND (G35) TSTM WIND (G35) 32
## TSTM WIND G45 TSTM WIND G45 32
## WINTER WEATHER WINTER WEATHER 33
## WARM WEATHER WARM WEATHER 33
## WINTER WEATHER MIX WINTER WEATHER MIX 33
## COLD WEATHER COLD WEATHER 33
## WINTER WEATHER/MIX WINTER WEATHER/MIX 33
## THUNDERSTORM THUNDERSTORM 34
## THUNDERSTORM WIND (G40) THUNDERSTORM WIND (G40) 34
## THUNDERSTORM WIND THUNDERSTORM WIND 34
## Hypothermia/Exposure Hypothermia/Exposure 35
## HYPOTHERMIA/EXPOSURE HYPOTHERMIA/EXPOSURE 36
## HYPERTHERMIA/EXPOSURE HYPERTHERMIA/EXPOSURE 36
## Lake Effect Snow Lake Effect Snow 37
## Mixed Precipitation Mixed Precipitation 38
## UNSEASONABLY COLD UNSEASONABLY COLD 39
## UNSEASONAL RAIN UNSEASONAL RAIN 39
## UNSEASONABLY WARM UNSEASONABLY WARM 39
## TSTM WIND AND LIGHTNING TSTM WIND AND LIGHTNING 40
## COASTAL FLOODING/EROSION COASTAL FLOODING/EROSION 41
## COASTAL FLOODING/EROSION COASTAL FLOODING/EROSION 41
## LAKE EFFECT SNOW LAKE EFFECT SNOW 42
## LATE SEASON SNOW LATE SEASON SNOW 42
## LAKE-EFFECT SNOW LAKE-EFFECT SNOW 42
## LIGHT FREEZING RAIN LIGHT FREEZING RAIN 43
## NON-SEVERE WIND DAMAGE NON-SEVERE WIND DAMAGE 44
## HIGH SURF ADVISORY HIGH SURF ADVISORY 45
## MARINE TSTM WIND MARINE TSTM WIND 46
## MARINE HIGH WIND MARINE HIGH WIND 46
## MARINE THUNDERSTORM WIND MARINE THUNDERSTORM WIND 46
## MARINE STRONG WIND MARINE STRONG WIND 46
## HURRICANE/TYPHOON HURRICANE/TYPHOON 47
## ASTRONOMICAL HIGH TIDE ASTRONOMICAL HIGH TIDE 48
## ASTRONOMICAL LOW TIDE ASTRONOMICAL LOW TIDE 48
## HEAVY SURF/HIGH SURF HEAVY SURF/HIGH SURF 49
## TROPICAL DEPRESSION TROPICAL DEPRESSION 50
This clustering analysis uses Levenshtein distance (a measure of the number of changes one has to make to one string to turn it into another) to put the weather event categories into clusters based on how close the words are. This can help us determine which strings to search to see which categories can be most reproducibly and accurately combined. See section “Limitations of the Analysis” for more information.
From the above list, I decided to combine the following categories:
TORNADO, WATERSPOUT TORNADO, WATERSPOUT/TORNADO, “TORNADOES, TSTM WIND, HAIL”, TORNADO F3, TORNADO F2
stormdata$EVTYPE[grepl("tornado",stormdata$EVTYPE, ignore.case = TRUE)]<-"TORNADO"Mudslides, Mudslide
stormdata$EVTYPE[grepl("mud",stormdata$EVTYPE, ignore.case = TRUE)]<-"MUDSLIDE"ICY ROADS, ICE ROADS, ICE ON ROAD
stormdata$EVTYPE[grepl("road",stormdata$EVTYPE, ignore.case = TRUE)]<-"ICY ROADS"Gusty winds, Gusty Winds, GUSTY WINDS, STRONG WIND, STRONG WINDS, GUSTY WIND
stormdata$EVTYPE[grepl("gust",stormdata$EVTYPE, ignore.case = TRUE)]<-"HIGH WINDS"THUNDERSTORM, THUNDERSTORMW, THUNDERSTORM WINDS, THUNDERSTORM WINDS/HAIL, THUNDERSTORM WIND, THUNDERSTORM WINDSS, THUNDERSTORM WINDS 13, THUNDERTORM WINDS, THUNDERSTORM WIND G52, THUNDERSTORM WINDS, THUNDERSTORMS WINDS, THUNDERSTORM WIND (G40), MARINE THUNDERSTORM WIND, LIGHTNING AND THUNDERSTORM WIN
stormdata$EVTYPE[grepl("thunder[s]?torm",stormdata$EVTYPE, ignore.case = TRUE)]<-"THUNDERSTORM/THUNDERSTORM WINDS"HURRICANE OPAL/HIGH WINDS, HIGH WIND, HIGH WIND/SEAS, HIGH WINDS, WINTER STORM HIGH WINDS, HEAVY SNOW AND HIGH WINDS, HIGH WIND/HEAVY SNOW, HIGH WINDS/COLD, SNOW/HIGH WINDS, HIGH WINDS/SNOW, HIGH WIND AND SEAS, HIGH WIND 48, MARINE HIGH WIND
stormdata$EVTYPE[grepl("high wind",stormdata$EVTYPE, ignore.case = TRUE)]<-"HIGH WINDS"ICE STORM/FLASH FLOOD, FLASH FLOOD, FLASH FLOODING, FLASH FLOODS, FLOOD/FLASH FLOOD, FLASH FLOOD/FLOOD, FLASH FLOODING/FLOOD
stormdata$EVTYPE[grepl("flash flood",stormdata$EVTYPE, ignore.case = TRUE)]<-"FLASH FLOODING"RIVER FLOOD, RIVER FLOODING, FLOOD/RIVER FLOOD, River Flooding
stormdata$EVTYPE[grepl("river flood",stormdata$EVTYPE, ignore.case = TRUE)]<-"RIVER FLOODING"HYPOTHERMIA, HYPOTHERMIA/EXPOSURE, Hypothermia/Exposure
stormdata$EVTYPE[grepl("hypothermia",stormdata$EVTYPE, ignore.case = TRUE)]<-"HYPOTHERMIA"STRONG WIND, STRONG WINDS, Strong Winds, MARINE STRONG WIND
stormdata$EVTYPE[grepl("strong wind",stormdata$EVTYPE, ignore.case = TRUE)]<-"HIGH WINDS"FREEZING RAIN/SNOW, FREEZING RAIN, FREEZING DRIZZLE, Freezing Spray
stormdata$EVTYPE[grepl("freezing",stormdata$EVTYPE, ignore.case = TRUE)]<-"FREEZING RAIN/SNOW"COASTAL STORM, COASTALSTORM, Coastal Storm
stormdata$EVTYPE[grepl("coastal[ ]?storm",stormdata$EVTYPE, ignore.case = TRUE)]<-"COASTAL STORM"Coastal Flooding, COASTAL FLOODING/EROSION, COASTAL FLOODING, COASTAL FLOOD
stormdata$EVTYPE[grepl("coastal flood",stormdata$EVTYPE, ignore.case = TRUE)]<-"COASTAL FLOODING"HIGH SURF, RIP CURRENTS/HEAVY SURF, HEAVY SURF, ROUGH SURF, Heavy Surf, High Surf, Heavy surf and wind, HAZARDOUS SURF, HEAVY SURF/HIGH SURF, HIGH WAVES
stormdata$EVTYPE[grepl("surf",stormdata$EVTYPE, ignore.case = TRUE)]<-"HIGH SURF"
stormdata$EVTYPE[grepl("high waves",stormdata$EVTYPE, ignore.case = TRUE)]<-"HIGH SURF"
head(stormdata)
## BGN_DATE END_DATE TIME_ZONE EVTYPE FATALITIES INJURIES
## 53316 1996-01-06 1/7/1996 0:00:00 CST WINTER STORM 0 0
## 53317 1996-01-11 1/11/1996 0:00:00 CST TORNADO 0 0
## 53318 1996-01-11 1/11/1996 0:00:00 CST TSTM WIND 0 0
## 53319 1996-01-11 1/11/1996 0:00:00 CST TSTM WIND 0 0
## 53320 1996-01-11 1/11/1996 0:00:00 CST TSTM WIND 0 0
## 53321 1996-01-18 1/19/1996 0:00:00 CST HIGH WINDS 0 0
## PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP
## 53316 380 K 38 K
## 53317 100 K 0
## 53318 3 K 0
## 53319 5 K 0
## 53320 2 K 0
## 53321 400 K 0
Looking at the current data frame, all the way to the right you can see columns called “PROPDMGEXP” and “CROPDMGEXP”. In the original data, there are many possible values (including +, -, 0, and 1-8) that are not clearly identified, but luckily, with the truncations and modifications we’ve made, there are really only four possible values for each of these columns.
unique(stormdata$PROPDMGEXP)
## [1] "K" "" "M" "B"
unique(stormdata$CROPDMGEXP)
## [1] "K" "" "M" "B"
The NOAA website was not at all clear about what these values mean, but these are fairly self explanatory. Additionally, here a student does the work of comparing the online version of the data to the database as we are given it, and confirms the following:
K = thousands
M = millions
B = billions
[blank] = no modifier
stormdata$PROPDMGEXP[stormdata$PROPDMGEXP=="K"]<-1000
stormdata$PROPDMGEXP[stormdata$PROPDMGEXP=="M"]<-1000000
stormdata$PROPDMGEXP[stormdata$PROPDMGEXP=="B"]<-1000000000
stormdata$PROPDMGEXP[stormdata$PROPDMGEXP==""]<-1
stormdata$CROPDMGEXP[stormdata$CROPDMGEXP=="K"]<-1000
stormdata$CROPDMGEXP[stormdata$CROPDMGEXP=="M"]<-1000000
stormdata$CROPDMGEXP[stormdata$CROPDMGEXP=="B"]<-1000000000
stormdata$CROPDMGEXP[stormdata$CROPDMGEXP==""]<-1
Now we can create a column where the “real” amount of damage can be expressed as a simple number.
stormdata$PROPDMGEXP<-as.numeric(stormdata$PROPDMGEXP)
stormdata$CROPDMGEXP<-as.numeric(stormdata$CROPDMGEXP)
stormdata<-stormdata%>%mutate(real_CD = CROPDMG * CROPDMGEXP, real_PD = PROPDMG * PROPDMGEXP)
We can now group by and summarize fatalities, injuries, crop damage, and property damage by event:
stormsum<-stormdata%>%group_by(EVTYPE)%>%summarize(num_fatal = sum(FATALITIES), avg_fatal = mean(FATALITIES), num_inj = sum(INJURIES), avg_inj = mean(INJURIES), sum_PD = sum(real_PD), sum_CD = sum(real_CD), avg_PD = mean(real_PD), avg_CD = mean(real_CD))
head(stormsum)
## # A tibble: 6 × 9
## EVTYPE num_fatal avg_fatal num_inj avg_inj sum_PD sum_CD avg_PD avg_CD
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 " TSTM WIND" 0 0 0 0 8.10e6 0 4.05e6 0
## 2 " TSTM WIND (… 0 0 0 0 8 e3 0 8 e3 0
## 3 "AGRICULTURAL… 0 0 0 0 0 2.88e7 0 9.61e6
## 4 "ASTRONOMICAL… 0 0 0 0 9.42e6 0 1.18e6 0
## 5 "ASTRONOMICAL… 0 0 0 0 3.20e5 0 1.6 e5 0
## 6 "AVALANCHE" 223 0.845 156 0.591 3.71e6 0 1.41e4 0
In this table, remember “CD” means “crop damage” and “PD” means property damage. This is the table we’ll use to see what the top offenders are for each type of damage.
Finally, most events, even with our focusing in the beginning, will still have a low number of injuries, fatalities, and damage. As an example, let’s look at the fatalities:
with(stormsum, hist(avg_fatal, main = "Fatalities by Event", xlab = "Average Number of Fatalities"))
Each of the damage types—crop, property, fatalities, and injuries—follows this same pattern, with most existing at zero or near zero. It muddies up the waters considerably, when all we are really interested in is what is the most damaging. Let’s arrange and subset this table for each damage type to look at the top ten.
topPD<-stormsum%>%arrange(desc(avg_PD))%>%slice_head(n=10)
topCD<-stormsum%>%arrange(desc(avg_CD))%>%slice_head(n=10)
topfatal<-stormsum%>%arrange(desc(avg_fatal))%>%slice_head(n=10)
topinj<-stormsum%>%arrange(desc(avg_inj))%>%slice_head(n=10)
Below is a plot of the average cost of the top ten most damaging event types for the two major categories of damage—economic (property and crop damage) and human health (injuries and fatalities). I chose to use overall average per event type as the metric, but you would get different answers if you chose to see the total damage over time, or the average for each year for each event type. See the section “Limitations of the Analysis” for more information.
library(ggplot2)
pc<-ggplot(data = topPD, aes(x = EVTYPE))+geom_col(aes(y = avg_PD), fill = "pink")+geom_col(data = topCD,aes(x = EVTYPE, y = avg_CD), fill = "black")+theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust = 1, size = 6))+labs(x = NULL, title = "Avg Property and Crop Damage by Event", y = "Cost ($)")
library(ggpubr)
g <- ggplotGrob(pc)
g[[1]][[13]]$children[[1]]$label <- c("Cost $ (Property);", "Cost $ (Crop)")
g[[1]][[13]]$children[[1]]$gp$col <- c("pink", "black")
g[[1]][[13]]$children[[1]]$hjust <- c(1, 0)
g[[1]][[13]]$children[[1]]$y <- unit(c(0.2, 0.2), "npc")
fi<-ggplot(data = topinj, aes(x = EVTYPE))+geom_col(aes(y = avg_inj), fill = "blue")+geom_col(data = topfatal,aes(x = EVTYPE, y = avg_fatal), fill = "aquamarine")+theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust = 1, size = 6))+labs(x = NULL, title = "Avg Injuries and Fatalities by Event", y = "Number")
h <- ggplotGrob(fi)
h[[1]][[13]]$children[[1]]$label <- c("Injuries;", "Fatalities")
h[[1]][[13]]$children[[1]]$gp$col <- c("blue", "aquamarine")
h[[1]][[13]]$children[[1]]$hjust <- c(1, 0)
h[[1]][[13]]$children[[1]]$y <- unit(c(0.2, 0.2), "npc")
figure<-ggarrange(g,h,ncol = 1, nrow = 2)
figure
By these metrics, the worst event type for each damage type is as follows (in parentheses, the conclusion if total numbers as opposed to overall average were used):
-injuries: heat wave (heat wave)
-fatalities: cold and snow (excessive heat)
-property damage: hurricane/typhoon (flood)
-crop damage: drought (drought)
For “human damages”, both injuries could be prevented efficiently by focusing on remediation of the effects of heat waves or excessive heat, generally. Cold and snow are also responsible for the highest average number of fatalities. It would also do to focus on excessive heat for the sake of fatalities, since it shows up in both the top ten injurious and top ten fatal event types, and, if sorted by total instead of average, would be the most fatal event type. To prevent the most property damage, it’s best to prepare heavily for hurricanes and typhoons. Lastly, in terms of crop damage, drought should be focused on.
There are a few limitations to our analysis. First, not all actually same categories could be reproducibly merged. I went with a conservative approach, hoping to avoid merging categories that didn’t actually refer to the same thing, but this led to many actual repeats that couldn’t be merged. With the damages, economic and human, artificially spread out like that, some event types might be under counted in severity. Efforts should be undertaken on the database level to clean the data and control for these categories during data entry.
Additionally, I didn’t separate by year. The most deadly or costly events could be changing in response to climate change, for example, or otherwise be changing over time. The most injurious event types today might not be so in the future.
Finally, I chose to define the event types with the most impact as those that had the highest overall average damage, fatalities, or injuries. We get different answers based on what metrics we use.