Synopsis

This data analysis uses the National Oceanic and Atmospheric Administration (NOAA) Storm Data to explore which severe weather events have the largest impacts on population health and the economy. The NOAA Storm Data only permits entry of specific storm data events, but inspection of unique storm data events in the data set revealed that many entries deviated from permitted storm data events. In addition, capitalization and formatting differed between entries and other entries were misspelled. Thus, event descriptions were cleaned to remove formatting variations, capitalize all letters, and autmatically correct misspellings. Next, the analysis quantified how often each single word was contained in event descriptions, and derived a list of any weather-related words with more than 100 occurences. Severe weather events that contained one of these weather-related words were then re-coded as this weather-related event, going through the list of weather-related word from most to least common occurence. Afterward, the analysis totals the reported fatalities and injuries by these standardized weather-related events to determine which severe weather events have the largest impact on population health. Property and crop damage amounts are converted to dollar amounts using damage-magnitude indicators from the data set, and are also totaled by standardized weather-related events to determine which severe weather events have the largest impact on the economy. Given that standardization of weather-related events utilizes a text-matching heuristic, the resulting categories must be interpreted as approximate groupings rather than official NOAA classifications.

Data Processing

Loading the data

The analysis uses multiple libraries to summarize, manipulate, correct, and visualize the data. The following lines of code load these libraries.

library(ggplot2)   # Used to create data visualizations.
library(patchwork) # Allows multiple ggplot figures to be combined.
library(hunspell)  # Used to identify misspelled words and suggest corrections.
library(stringr)   # Provides functions for string manipulation.
library(dplyr)     # Used for data manipulation and summarization.
## 
## 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

Data Processing

Loading the data

The following lines of code load the data directly from the compressed csv-file, ‘repdata_data_StormData.csv.bz2’, by utilizing the read_csv function.

# Load the NOAA Storm Data
storm_data <- read.csv('./repdata_data_StormData.csv.bz2')

Preprocessing the data

Remove formatting variations and capitalize all letters

The following lines of code print the first 10 rows of the loaded data file, revealing that the column ‘EVTYPE’ contains strings classifying each severe weather event. In addition, the data contains the columns ‘FATALITIES’, ‘INJURIES’, ‘PROPDMG’, ‘CROPDMG’, ‘PROPDMGEXP’, and ‘CROPDMGEXP’ that respectively list the fatalities and injuries, the property and crop damage, and a magnitude multiplier for the property and crop damage amiunts for each severe weather event. This analysis will inspect these quantities later to determine which severe weather events have the largest impact on population health and the economy.

The following lines of code then print each unique severe weather event entry, revealing that severe weather event entries in this data set do not adhere to the NOAA storm data permitted severe weather events, that there are many variations in formatting and capitalization, and that some entries are misspelled.

# Print the first rows of data
head(storm_data, 10)
##    STATE__           BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1        1  4/18/1950 0:00:00     0130       CST     97     MOBILE    AL
## 2        1  4/18/1950 0:00:00     0145       CST      3    BALDWIN    AL
## 3        1  2/20/1951 0:00:00     1600       CST     57    FAYETTE    AL
## 4        1   6/8/1951 0:00:00     0900       CST     89    MADISON    AL
## 5        1 11/15/1951 0:00:00     1500       CST     43    CULLMAN    AL
## 6        1 11/15/1951 0:00:00     2000       CST     77 LAUDERDALE    AL
## 7        1 11/16/1951 0:00:00     0100       CST      9     BLOUNT    AL
## 8        1  1/22/1952 0:00:00     0900       CST    123 TALLAPOOSA    AL
## 9        1  2/13/1952 0:00:00     2000       CST    125 TUSCALOOSA    AL
## 10       1  2/13/1952 0:00:00     2000       CST     57    FAYETTE    AL
##     EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END COUNTYENDN
## 1  TORNADO         0                                               0         NA
## 2  TORNADO         0                                               0         NA
## 3  TORNADO         0                                               0         NA
## 4  TORNADO         0                                               0         NA
## 5  TORNADO         0                                               0         NA
## 6  TORNADO         0                                               0         NA
## 7  TORNADO         0                                               0         NA
## 8  TORNADO         0                                               0         NA
## 9  TORNADO         0                                               0         NA
## 10 TORNADO         0                                               0         NA
##    END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES INJURIES PROPDMG
## 1          0                      14.0   100 3   0          0       15    25.0
## 2          0                       2.0   150 2   0          0        0     2.5
## 3          0                       0.1   123 2   0          0        2    25.0
## 4          0                       0.0   100 2   0          0        2     2.5
## 5          0                       0.0   150 2   0          0        2     2.5
## 6          0                       1.5   177 2   0          0        6     2.5
## 7          0                       1.5    33 2   0          0        1     2.5
## 8          0                       0.0    33 1   0          0        0     2.5
## 9          0                       3.3   100 3   0          1       14    25.0
## 10         0                       2.3   100 3   0          0        0    25.0
##    PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES LATITUDE LONGITUDE
## 1           K       0                                         3040      8812
## 2           K       0                                         3042      8755
## 3           K       0                                         3340      8742
## 4           K       0                                         3458      8626
## 5           K       0                                         3412      8642
## 6           K       0                                         3450      8748
## 7           K       0                                         3405      8631
## 8           K       0                                         3255      8558
## 9           K       0                                         3334      8740
## 10          K       0                                         3336      8738
##    LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1        3051       8806              1
## 2           0          0              2
## 3           0          0              3
## 4           0          0              4
## 5           0          0              5
## 6           0          0              6
## 7           0          0              7
## 8           0          0              8
## 9        3336       8738              9
## 10       3337       8737             10
# Print unique severe weather events
unique(storm_data$EVTYPE)
##   [1] "TORNADO"                        "TSTM WIND"                     
##   [3] "HAIL"                           "FREEZING RAIN"                 
##   [5] "SNOW"                           "ICE STORM/FLASH FLOOD"         
##   [7] "SNOW/ICE"                       "WINTER STORM"                  
##   [9] "HURRICANE OPAL/HIGH WINDS"      "THUNDERSTORM WINDS"            
##  [11] "RECORD COLD"                    "HURRICANE ERIN"                
##  [13] "HURRICANE OPAL"                 "HEAVY RAIN"                    
##  [15] "LIGHTNING"                      "THUNDERSTORM WIND"             
##  [17] "DENSE FOG"                      "RIP CURRENT"                   
##  [19] "THUNDERSTORM WINS"              "FLASH FLOOD"                   
##  [21] "FLASH FLOODING"                 "HIGH WINDS"                    
##  [23] "FUNNEL CLOUD"                   "TORNADO F0"                    
##  [25] "THUNDERSTORM WINDS LIGHTNING"   "THUNDERSTORM WINDS/HAIL"       
##  [27] "HEAT"                           "WIND"                          
##  [29] "LIGHTING"                       "HEAVY RAINS"                   
##  [31] "LIGHTNING AND HEAVY RAIN"       "FUNNEL"                        
##  [33] "WALL CLOUD"                     "FLOODING"                      
##  [35] "THUNDERSTORM WINDS HAIL"        "FLOOD"                         
##  [37] "COLD"                           "HEAVY RAIN/LIGHTNING"          
##  [39] "FLASH FLOODING/THUNDERSTORM WI" "WALL CLOUD/FUNNEL CLOUD"       
##  [41] "THUNDERSTORM"                   "WATERSPOUT"                    
##  [43] "EXTREME COLD"                   "HAIL 1.75)"                    
##  [45] "LIGHTNING/HEAVY RAIN"           "HIGH WIND"                     
##  [47] "BLIZZARD"                       "BLIZZARD WEATHER"              
##  [49] "WIND CHILL"                     "BREAKUP FLOODING"              
##  [51] "HIGH WIND/BLIZZARD"             "RIVER FLOOD"                   
##  [53] "HEAVY SNOW"                     "FREEZE"                        
##  [55] "COASTAL FLOOD"                  "HIGH WIND AND HIGH TIDES"      
##  [57] "HIGH WIND/BLIZZARD/FREEZING RA" "HIGH TIDES"                    
##  [59] "HIGH WIND AND HEAVY SNOW"       "RECORD COLD AND HIGH WIND"     
##  [61] "RECORD HIGH TEMPERATURE"        "RECORD HIGH"                   
##  [63] "HIGH WINDS HEAVY RAINS"         "HIGH WIND/ BLIZZARD"           
##  [65] "ICE STORM"                      "BLIZZARD/HIGH WIND"            
##  [67] "HIGH WIND/LOW WIND CHILL"       "HEAVY SNOW/HIGH"               
##  [69] "RECORD LOW"                     "HIGH WINDS AND WIND CHILL"     
##  [71] "HEAVY SNOW/HIGH WINDS/FREEZING" "LOW TEMPERATURE RECORD"        
##  [73] "AVALANCHE"                      "MARINE MISHAP"                 
##  [75] "WIND CHILL/HIGH WIND"           "HIGH WIND/WIND CHILL/BLIZZARD" 
##  [77] "HIGH WIND/WIND CHILL"           "HIGH WIND/HEAVY SNOW"          
##  [79] "HIGH TEMPERATURE RECORD"        "FLOOD WATCH/"                  
##  [81] "RECORD HIGH TEMPERATURES"       "HIGH WIND/SEAS"                
##  [83] "HIGH WINDS/HEAVY RAIN"          "HIGH SEAS"                     
##  [85] "SEVERE TURBULENCE"              "RECORD RAINFALL"               
##  [87] "RECORD SNOWFALL"                "RECORD WARMTH"                 
##  [89] "HEAVY SNOW/WIND"                "EXTREME HEAT"                  
##  [91] "WIND DAMAGE"                    "DUST STORM"                    
##  [93] "APACHE COUNTY"                  "SLEET"                         
##  [95] "HAIL STORM"                     "FUNNEL CLOUDS"                 
##  [97] "FLASH FLOODS"                   "DUST DEVIL"                    
##  [99] "EXCESSIVE HEAT"                 "THUNDERSTORM WINDS/FUNNEL CLOU"
## [101] "WINTER STORM/HIGH WIND"         "WINTER STORM/HIGH WINDS"       
## [103] "GUSTY WINDS"                    "STRONG WINDS"                  
## [105] "FLOODING/HEAVY RAIN"            "SNOW AND WIND"                 
## [107] "HEAVY SURF COASTAL FLOODING"    "HEAVY SURF"                    
## [109] "HEAVY PRECIPATATION"            "URBAN FLOODING"                
## [111] "HIGH SURF"                      "BLOWING DUST"                  
## [113] "URBAN/SMALL"                    "WILD FIRES"                    
## [115] "HIGH"                           "URBAN/SMALL FLOODING"          
## [117] "WATER SPOUT"                    "HIGH WINDS DUST STORM"         
## [119] "WINTER STORM HIGH WINDS"        "LOCAL FLOOD"                   
## [121] "WINTER STORMS"                  "MUDSLIDES"                     
## [123] "RAINSTORM"                      "SEVERE THUNDERSTORM"           
## [125] "SEVERE THUNDERSTORMS"           "SEVERE THUNDERSTORM WINDS"     
## [127] "THUNDERSTORMS WINDS"            "DRY MICROBURST"                
## [129] "FLOOD/FLASH FLOOD"              "FLOOD/RAIN/WINDS"              
## [131] "WINDS"                          "DRY MICROBURST 61"             
## [133] "THUNDERSTORMS"                  "FLASH FLOOD WINDS"             
## [135] "URBAN/SMALL STREAM FLOODING"    "MICROBURST"                    
## [137] "STRONG WIND"                    "HIGH WIND DAMAGE"              
## [139] "STREAM FLOODING"                "URBAN AND SMALL"               
## [141] "HEAVY SNOWPACK"                 "ICE"                           
## [143] "FLASH FLOOD/"                   "DOWNBURST"                     
## [145] "GUSTNADO AND"                   "FLOOD/RAIN/WIND"               
## [147] "WET MICROBURST"                 "DOWNBURST WINDS"               
## [149] "DRY MICROBURST WINDS"           "DRY MIRCOBURST WINDS"          
## [151] "DRY MICROBURST 53"              "SMALL STREAM URBAN FLOOD"      
## [153] "MICROBURST WINDS"               "HIGH WINDS 57"                 
## [155] "DRY MICROBURST 50"              "HIGH WINDS 66"                 
## [157] "HIGH WINDS 76"                  "HIGH WINDS 63"                 
## [159] "HIGH WINDS 67"                  "BLIZZARD/HEAVY SNOW"           
## [161] "HEAVY SNOW/HIGH WINDS"          "BLOWING SNOW"                  
## [163] "HIGH WINDS 82"                  "HIGH WINDS 80"                 
## [165] "HIGH WINDS 58"                  "FREEZING DRIZZLE"              
## [167] "LIGHTNING THUNDERSTORM WINDSS"  "DRY MICROBURST 58"             
## [169] "HAIL 75"                        "HIGH WINDS 73"                 
## [171] "HIGH WINDS 55"                  "LIGHT SNOW AND SLEET"          
## [173] "URBAN FLOOD"                    "DRY MICROBURST 84"             
## [175] "THUNDERSTORM WINDS 60"          "HEAVY RAIN/FLOODING"           
## [177] "THUNDERSTORM WINDSS"            "TORNADOS"                      
## [179] "GLAZE"                          "RECORD HEAT"                   
## [181] "COASTAL FLOODING"               "HEAT WAVE"                     
## [183] "FIRST SNOW"                     "FREEZING RAIN AND SLEET"       
## [185] "UNSEASONABLY DRY"               "UNSEASONABLY WET"              
## [187] "WINTRY MIX"                     "WINTER WEATHER"                
## [189] "UNSEASONABLY COLD"              "EXTREME/RECORD COLD"           
## [191] "RIP CURRENTS HEAVY SURF"        "SLEET/RAIN/SNOW"               
## [193] "UNSEASONABLY WARM"              "DROUGHT"                       
## [195] "NORMAL PRECIPITATION"           "HIGH WINDS/FLOODING"           
## [197] "DRY"                            "RAIN/SNOW"                     
## [199] "SNOW/RAIN/SLEET"                "WATERSPOUT/TORNADO"            
## [201] "WATERSPOUTS"                    "WATERSPOUT TORNADO"            
## [203] "URBAN/SMALL STREAM FLOOD"       "STORM SURGE"                   
## [205] "WATERSPOUT-TORNADO"             "WATERSPOUT-"                   
## [207] "TORNADOES, TSTM WIND, HAIL"     "TROPICAL STORM ALBERTO"        
## [209] "TROPICAL STORM"                 "TROPICAL STORM GORDON"         
## [211] "TROPICAL STORM JERRY"           "LIGHTNING THUNDERSTORM WINDS"  
## [213] "WAYTERSPOUT"                    "MINOR FLOODING"                
## [215] "LIGHTNING INJURY"               "URBAN/SMALL STREAM  FLOOD"     
## [217] "LIGHTNING AND THUNDERSTORM WIN" "THUNDERSTORM WINDS53"          
## [219] "URBAN AND SMALL STREAM FLOOD"   "URBAN AND SMALL STREAM"        
## [221] "WILDFIRE"                       "DAMAGING FREEZE"               
## [223] "THUNDERSTORM WINDS 13"          "SMALL HAIL"                    
## [225] "HEAVY SNOW/HIGH WIND"           "HURRICANE"                     
## [227] "WILD/FOREST FIRE"               "SMALL STREAM FLOODING"         
## [229] "MUD SLIDE"                      "LIGNTNING"                     
## [231] "FROST"                          "FREEZING RAIN/SNOW"            
## [233] "HIGH WINDS/"                    "THUNDERSNOW"                   
## [235] "FLOODS"                         "EXTREME WIND CHILLS"           
## [237] "COOL AND WET"                   "HEAVY RAIN/SNOW"               
## [239] "SMALL STREAM AND URBAN FLOODIN" "SMALL STREAM/URBAN FLOOD"      
## [241] "SNOW/SLEET/FREEZING RAIN"       "SEVERE COLD"                   
## [243] "GLAZE ICE"                      "COLD WAVE"                     
## [245] "EARLY SNOW"                     "SMALL STREAM AND URBAN FLOOD"  
## [247] "HIGH  WINDS"                    "RURAL FLOOD"                   
## [249] "SMALL STREAM AND"               "MUD SLIDES"                    
## [251] "HAIL 80"                        "EXTREME WIND CHILL"            
## [253] "COLD AND WET CONDITIONS"        "EXCESSIVE WETNESS"             
## [255] "GRADIENT WINDS"                 "HEAVY SNOW/BLOWING SNOW"       
## [257] "SLEET/ICE STORM"                "THUNDERSTORM WINDS URBAN FLOOD"
## [259] "THUNDERSTORM WINDS SMALL STREA" "ROTATING WALL CLOUD"           
## [261] "LARGE WALL CLOUD"               "COLD AIR FUNNEL"               
## [263] "GUSTNADO"                       "COLD AIR FUNNELS"              
## [265] "BLOWING SNOW- EXTREME WIND CHI" "SNOW AND HEAVY SNOW"           
## [267] "GROUND BLIZZARD"                "MAJOR FLOOD"                   
## [269] "SNOW/HEAVY SNOW"                "FREEZING RAIN/SLEET"           
## [271] "ICE JAM FLOODING"               "SNOW- HIGH WIND- WIND CHILL"   
## [273] "STREET FLOOD"                   "COLD AIR TORNADO"              
## [275] "SMALL STREAM FLOOD"             "FOG"                           
## [277] "THUNDERSTORM WINDS 2"           "FUNNEL CLOUD/HAIL"             
## [279] "ICE/SNOW"                       "TSTM WIND 51"                  
## [281] "TSTM WIND 50"                   "TSTM WIND 52"                  
## [283] "TSTM WIND 55"                   "HEAVY SNOW/BLIZZARD"           
## [285] "THUNDERSTORM WINDS 61"          "HAIL 0.75"                     
## [287] "THUNDERSTORM DAMAGE"            "THUNDERTORM WINDS"             
## [289] "HAIL 1.00"                      "HAIL/WINDS"                    
## [291] "SNOW AND ICE"                   "WIND STORM"                    
## [293] "SNOWSTORM"                      "GRASS FIRES"                   
## [295] "LAKE FLOOD"                     "PROLONG COLD"                  
## [297] "HAIL/WIND"                      "HAIL 1.75"                     
## [299] "THUNDERSTORMW 50"               "WIND/HAIL"                     
## [301] "SNOW AND ICE STORM"             "URBAN AND SMALL STREAM FLOODIN"
## [303] "THUNDERSTORMS WIND"             "THUNDERSTORM  WINDS"           
## [305] "HEAVY SNOW/SLEET"               "AGRICULTURAL FREEZE"           
## [307] "DROUGHT/EXCESSIVE HEAT"         "TUNDERSTORM WIND"              
## [309] "TROPICAL STORM DEAN"            "THUNDERTSORM WIND"             
## [311] "THUNDERSTORM WINDS/ HAIL"       "THUNDERSTORM WIND/LIGHTNING"   
## [313] "HEAVY RAIN/SEVERE WEATHER"      "THUNDESTORM WINDS"             
## [315] "WATERSPOUT/ TORNADO"            "LIGHTNING."                    
## [317] "WARM DRY CONDITIONS"            "HURRICANE-GENERATED SWELLS"    
## [319] "HEAVY SNOW/ICE STORM"           "RIVER AND STREAM FLOOD"        
## [321] "HIGH WIND 63"                   "COASTAL SURGE"                 
## [323] "HEAVY SNOW AND ICE STORM"       "MINOR FLOOD"                   
## [325] "HIGH WINDS/COASTAL FLOOD"       "RAIN"                          
## [327] "RIVER FLOODING"                 "SNOW/RAIN"                     
## [329] "ICE FLOES"                      "HIGH WAVES"                    
## [331] "SNOW SQUALLS"                   "SNOW SQUALL"                   
## [333] "THUNDERSTORM WIND G50"          "LIGHTNING FIRE"                
## [335] "BLIZZARD/FREEZING RAIN"         "HEAVY LAKE SNOW"               
## [337] "HEAVY SNOW/FREEZING RAIN"       "LAKE EFFECT SNOW"              
## [339] "HEAVY WET SNOW"                 "DUST DEVIL WATERSPOUT"         
## [341] "THUNDERSTORM WINDS/HEAVY RAIN"  "THUNDERSTROM WINDS"            
## [343] "THUNDERSTORM WINDS      LE CEN" "HAIL 225"                      
## [345] "BLIZZARD AND HEAVY SNOW"        "HEAVY SNOW AND ICE"            
## [347] "ICE STORM AND SNOW"             "HEAVY SNOW ANDBLOWING SNOW"    
## [349] "HEAVY SNOW/ICE"                 "BLIZZARD AND EXTREME WIND CHIL"
## [351] "LOW WIND CHILL"                 "BLOWING SNOW & EXTREME WIND CH"
## [353] "WATERSPOUT/"                    "URBAN/SMALL STREAM"            
## [355] "TORNADO F3"                     "FUNNEL CLOUD."                 
## [357] "TORNDAO"                        "HAIL 0.88"                     
## [359] "FLOOD/RIVER FLOOD"              "MUD SLIDES URBAN FLOODING"     
## [361] "TORNADO F1"                     "THUNDERSTORM WINDS G"          
## [363] "DEEP HAIL"                      "GLAZE/ICE STORM"               
## [365] "HEAVY SNOW/WINTER STORM"        "AVALANCE"                      
## [367] "BLIZZARD/WINTER STORM"          "DUST STORM/HIGH WINDS"         
## [369] "ICE JAM"                        "FOREST FIRES"                  
## [371] "THUNDERSTORM WIND G60"          "FROST\\FREEZE"                 
## [373] "THUNDERSTORM WINDS."            "HAIL 88"                       
## [375] "HAIL 175"                       "HVY RAIN"                      
## [377] "HAIL 100"                       "HAIL 150"                      
## [379] "HAIL 075"                       "THUNDERSTORM WIND G55"         
## [381] "HAIL 125"                       "THUNDERSTORM WINDS G60"        
## [383] "HARD FREEZE"                    "HAIL 200"                      
## [385] "THUNDERSTORM WINDS FUNNEL CLOU" "THUNDERSTORM WINDS 62"         
## [387] "WILDFIRES"                      "RECORD HEAT WAVE"              
## [389] "HEAVY SNOW AND HIGH WINDS"      "HEAVY SNOW/HIGH WINDS & FLOOD" 
## [391] "HAIL FLOODING"                  "THUNDERSTORM WINDS/FLASH FLOOD"
## [393] "HIGH WIND 70"                   "WET SNOW"                      
## [395] "HEAVY RAIN AND FLOOD"           "LOCAL FLASH FLOOD"             
## [397] "THUNDERSTORM WINDS 53"          "FLOOD/FLASH FLOODING"          
## [399] "TORNADO/WATERSPOUT"             "RAIN AND WIND"                 
## [401] "THUNDERSTORM WIND 59"           "THUNDERSTORM WIND 52"          
## [403] "COASTAL/TIDAL FLOOD"            "SNOW/ICE STORM"                
## [405] "BELOW NORMAL PRECIPITATION"     "RIP CURRENTS/HEAVY SURF"       
## [407] "FLASH FLOOD/FLOOD"              "EXCESSIVE RAIN"                
## [409] "RECORD/EXCESSIVE HEAT"          "HEAT WAVES"                    
## [411] "LIGHT SNOW"                     "THUNDERSTORM WIND 69"          
## [413] "HAIL DAMAGE"                    "LIGHTNING DAMAGE"              
## [415] "RECORD TEMPERATURES"            "LIGHTNING AND WINDS"           
## [417] "FOG AND COLD TEMPERATURES"      "OTHER"                         
## [419] "RECORD SNOW"                    "SNOW/COLD"                     
## [421] "FLASH FLOOD FROM ICE JAMS"      "TSTM WIND G58"                 
## [423] "MUDSLIDE"                       "HEAVY SNOW SQUALLS"            
## [425] "HEAVY SNOW/SQUALLS"             "HEAVY SNOW-SQUALLS"            
## [427] "ICY ROADS"                      "HEAVY MIX"                     
## [429] "SNOW FREEZING RAIN"             "LACK OF SNOW"                  
## [431] "SNOW/SLEET"                     "SNOW/FREEZING RAIN"            
## [433] "SNOW DROUGHT"                   "THUNDERSTORMW WINDS"           
## [435] "THUNDERSTORM WIND 60 MPH"       "THUNDERSTORM WIND 65MPH"       
## [437] "THUNDERSTORM WIND/ TREES"       "THUNDERSTORM WIND/AWNING"      
## [439] "THUNDERSTORM WIND 98 MPH"       "THUNDERSTORM WIND TREES"       
## [441] "TORRENTIAL RAIN"                "TORNADO F2"                    
## [443] "RIP CURRENTS"                   "HURRICANE EMILY"               
## [445] "HURRICANE GORDON"               "HURRICANE FELIX"               
## [447] "THUNDERSTORM WIND 59 MPH"       "THUNDERSTORM WINDS 63 MPH"     
## [449] "THUNDERSTORM WIND/ TREE"        "THUNDERSTORM DAMAGE TO"        
## [451] "THUNDERSTORM WIND 65 MPH"       "FLASH FLOOD - HEAVY RAIN"      
## [453] "THUNDERSTORM WIND."             "FLASH FLOOD/ STREET"           
## [455] "THUNDERSTORM WIND 59 MPH."      "HEAVY SNOW   FREEZING RAIN"    
## [457] "DAM FAILURE"                    "THUNDERSTORM HAIL"             
## [459] "HAIL 088"                       "THUNDERSTORM WINDSHAIL"        
## [461] "LIGHTNING  WAUSEON"             "THUDERSTORM WINDS"             
## [463] "ICE AND SNOW"                   "RECORD COLD/FROST"             
## [465] "STORM FORCE WINDS"              "FREEZING RAIN AND SNOW"        
## [467] "FREEZING RAIN SLEET AND"        "SOUTHEAST"                     
## [469] "HEAVY SNOW & ICE"               "FREEZING DRIZZLE AND FREEZING" 
## [471] "THUNDERSTORM WINDS AND"         "HAIL/ICY ROADS"                
## [473] "FLASH FLOOD/HEAVY RAIN"         "HEAVY RAIN; URBAN FLOOD WINDS;"
## [475] "HEAVY PRECIPITATION"            "TSTM WIND DAMAGE"              
## [477] "HIGH WATER"                     "FLOOD FLASH"                   
## [479] "RAIN/WIND"                      "THUNDERSTORM WINDS 50"         
## [481] "THUNDERSTORM WIND G52"          "FLOOD FLOOD/FLASH"             
## [483] "THUNDERSTORM WINDS 52"          "SNOW SHOWERS"                  
## [485] "THUNDERSTORM WIND G51"          "HEAT WAVE DROUGHT"             
## [487] "HEAVY SNOW/BLIZZARD/AVALANCHE"  "RECORD SNOW/COLD"              
## [489] "WET WEATHER"                    "UNSEASONABLY WARM AND DRY"     
## [491] "FREEZING RAIN SLEET AND LIGHT"  "RECORD/EXCESSIVE RAINFALL"     
## [493] "TIDAL FLOOD"                    "BEACH EROSIN"                  
## [495] "THUNDERSTORM WIND G61"          "FLOOD/FLASH"                   
## [497] "LOW TEMPERATURE"                "SLEET & FREEZING RAIN"         
## [499] "HEAVY RAINS/FLOODING"           "THUNDERESTORM WINDS"           
## [501] "THUNDERSTORM WINDS/FLOODING"    "THUNDEERSTORM WINDS"           
## [503] "HIGHWAY FLOODING"               "THUNDERSTORM W INDS"           
## [505] "HYPOTHERMIA"                    "FLASH FLOOD/ FLOOD"            
## [507] "THUNDERSTORM WIND 50"           "THUNERSTORM WINDS"             
## [509] "HEAVY RAIN/MUDSLIDES/FLOOD"     "MUD/ROCK SLIDE"                
## [511] "HIGH WINDS/COLD"                "BEACH EROSION/COASTAL FLOOD"   
## [513] "COLD/WINDS"                     "SNOW/ BITTER COLD"             
## [515] "THUNDERSTORM WIND 56"           "SNOW SLEET"                    
## [517] "DRY HOT WEATHER"                "COLD WEATHER"                  
## [519] "RAPIDLY RISING WATER"           "HAIL ALOFT"                    
## [521] "EARLY FREEZE"                   "ICE/STRONG WINDS"              
## [523] "EXTREME WIND CHILL/BLOWING SNO" "SNOW/HIGH WINDS"               
## [525] "HIGH WINDS/SNOW"                "EARLY FROST"                   
## [527] "SNOWMELT FLOODING"              "HEAVY SNOW AND STRONG WINDS"   
## [529] "SNOW ACCUMULATION"              "BLOWING SNOW/EXTREME WIND CHIL"
## [531] "SNOW/ ICE"                      "SNOW/BLOWING SNOW"             
## [533] "TORNADOES"                      "THUNDERSTORM WIND/HAIL"        
## [535] "FLASH FLOODING/FLOOD"           "HAIL 275"                      
## [537] "HAIL 450"                       "FLASH FLOOODING"               
## [539] "EXCESSIVE RAINFALL"             "THUNDERSTORMW"                 
## [541] "HAILSTORM"                      "TSTM WINDS"                    
## [543] "BEACH FLOOD"                    "HAILSTORMS"                    
## [545] "TSTMW"                          "FUNNELS"                       
## [547] "TSTM WIND 65)"                  "THUNDERSTORM WINDS/ FLOOD"     
## [549] "HEAVY RAINFALL"                 "HEAT/DROUGHT"                  
## [551] "HEAT DROUGHT"                   "NEAR RECORD SNOW"              
## [553] "LANDSLIDE"                      "HIGH WIND AND SEAS"            
## [555] "THUNDERSTORMWINDS"              "THUNDERSTORM WINDS HEAVY RAIN" 
## [557] "SLEET/SNOW"                     "EXCESSIVE"                     
## [559] "SNOW/SLEET/RAIN"                "WILD/FOREST FIRES"             
## [561] "HEAVY SEAS"                     "DUSTSTORM"                     
## [563] "FLOOD & HEAVY RAIN"             "?"                             
## [565] "THUNDERSTROM WIND"              "FLOOD/FLASHFLOOD"              
## [567] "SNOW AND COLD"                  "HOT PATTERN"                   
## [569] "PROLONG COLD/SNOW"              "BRUSH FIRES"                   
## [571] "SNOW\\COLD"                     "WINTER MIX"                    
## [573] "EXCESSIVE PRECIPITATION"        "SNOWFALL RECORD"               
## [575] "HOT/DRY PATTERN"                "DRY PATTERN"                   
## [577] "MILD/DRY PATTERN"               "MILD PATTERN"                  
## [579] "LANDSLIDES"                     "HEAVY SHOWERS"                 
## [581] "HEAVY SNOW AND"                 "HIGH WIND 48"                  
## [583] "LAKE-EFFECT SNOW"               "BRUSH FIRE"                    
## [585] "WATERSPOUT FUNNEL CLOUD"        "URBAN SMALL STREAM FLOOD"      
## [587] "SAHARAN DUST"                   "HEAVY SHOWER"                  
## [589] "URBAN FLOOD LANDSLIDE"          "HEAVY SWELLS"                  
## [591] "URBAN SMALL"                    "URBAN FLOODS"                  
## [593] "SMALL STREAM"                   "HEAVY RAIN/URBAN FLOOD"        
## [595] "FLASH FLOOD/LANDSLIDE"          "LANDSLIDE/URBAN FLOOD"         
## [597] "HEAVY RAIN/SMALL STREAM URBAN"  "FLASH FLOOD LANDSLIDES"        
## [599] "EXTREME WINDCHILL"              "URBAN/SML STREAM FLD"          
## [601] "TSTM WIND/HAIL"                 "Other"                         
## [603] "Record dry month"               "Temperature record"            
## [605] "Minor Flooding"                 "Ice jam flood (minor"          
## [607] "High Wind"                      "Tstm Wind"                     
## [609] "ROUGH SURF"                     "Wind"                          
## [611] "Heavy Surf"                     "Dust Devil"                    
## [613] "Wind Damage"                    "Marine Accident"               
## [615] "Snow"                           "Freeze"                        
## [617] "Snow Squalls"                   "Coastal Flooding"              
## [619] "Heavy Rain"                     "Strong Wind"                   
## [621] "COASTAL STORM"                  "COASTALFLOOD"                  
## [623] "Erosion/Cstl Flood"             "Heavy Rain and Wind"           
## [625] "Light Snow/Flurries"            "Wet Month"                     
## [627] "Wet Year"                       "Tidal Flooding"                
## [629] "River Flooding"                 "Damaging Freeze"               
## [631] "Beach Erosion"                  "Hot and Dry"                   
## [633] "Flood/Flash Flood"              "Icy Roads"                     
## [635] "High Surf"                      "Heavy Rain/High Surf"          
## [637] "Thunderstorm Wind"              "Rain Damage"                   
## [639] "Unseasonable Cold"              "Early Frost"                   
## [641] "Wintry Mix"                     "blowing snow"                  
## [643] "STREET FLOODING"                "Record Cold"                   
## [645] "Extreme Cold"                   "Ice Fog"                       
## [647] "Excessive Cold"                 "Torrential Rainfall"           
## [649] "Freezing Rain"                  "Landslump"                     
## [651] "Late-season Snowfall"           "Hurricane Edouard"             
## [653] "Coastal Storm"                  "Flood"                         
## [655] "HEAVY RAIN/WIND"                "TIDAL FLOODING"                
## [657] "Winter Weather"                 "Snow squalls"                  
## [659] "Strong Winds"                   "Strong winds"                  
## [661] "RECORD WARM TEMPS."             "Ice/Snow"                      
## [663] "Mudslide"                       "Glaze"                         
## [665] "Extended Cold"                  "Snow Accumulation"             
## [667] "Freezing Fog"                   "Drifting Snow"                 
## [669] "Whirlwind"                      "Heavy snow shower"             
## [671] "Heavy rain"                     "LATE SNOW"                     
## [673] "Record May Snow"                "Record Winter Snow"            
## [675] "Heavy Precipitation"            " COASTAL FLOOD"                
## [677] "Record temperature"             "Light snow"                    
## [679] "Late Season Snowfall"           "Gusty Wind"                    
## [681] "small hail"                     "Light Snow"                    
## [683] "MIXED PRECIP"                   "Black Ice"                     
## [685] "Mudslides"                      "Gradient wind"                 
## [687] "Snow and Ice"                   "Freezing Spray"                
## [689] "Summary Jan 17"                 "Summary of March 14"           
## [691] "Summary of March 23"            "Summary of March 24"           
## [693] "Summary of April 3rd"           "Summary of April 12"           
## [695] "Summary of April 13"            "Summary of April 21"           
## [697] "Summary August 11"              "Summary of April 27"           
## [699] "Summary of May 9-10"            "Summary of May 10"             
## [701] "Summary of May 13"              "Summary of May 14"             
## [703] "Summary of May 22 am"           "Summary of May 22 pm"          
## [705] "Heatburst"                      "Summary of May 26 am"          
## [707] "Summary of May 26 pm"           "Metro Storm, May 26"           
## [709] "Summary of May 31 am"           "Summary of May 31 pm"          
## [711] "Summary of June 3"              "Summary of June 4"             
## [713] "Summary June 5-6"               "Summary June 6"                
## [715] "Summary of June 11"             "Summary of June 12"            
## [717] "Summary of June 13"             "Summary of June 15"            
## [719] "Summary of June 16"             "Summary June 18-19"            
## [721] "Summary of June 23"             "Summary of June 24"            
## [723] "Summary of June 30"             "Summary of July 2"             
## [725] "Summary of July 3"              "Summary of July 11"            
## [727] "Summary of July 22"             "Summary July 23-24"            
## [729] "Summary of July 26"             "Summary of July 29"            
## [731] "Summary of August 1"            "Summary August 2-3"            
## [733] "Summary August 7"               "Summary August 9"              
## [735] "Summary August 10"              "Summary August 17"             
## [737] "Summary August 21"              "Summary August 28"             
## [739] "Summary September 4"            "Summary September 20"          
## [741] "Summary September 23"           "Summary Sept. 25-26"           
## [743] "Summary: Oct. 20-21"            "Summary: October 31"           
## [745] "Summary: Nov. 6-7"              "Summary: Nov. 16"              
## [747] "Microburst"                     "wet micoburst"                 
## [749] "Hail(0.75)"                     "Funnel Cloud"                  
## [751] "Urban Flooding"                 "No Severe Weather"             
## [753] "Urban flood"                    "Urban Flood"                   
## [755] "Cold"                           "Summary of May 22"             
## [757] "Summary of June 6"              "Summary August 4"              
## [759] "Summary of June 10"             "Summary of June 18"            
## [761] "Summary September 3"            "Summary: Sept. 18"             
## [763] "Coastal Flood"                  "coastal flooding"              
## [765] "Small Hail"                     "Record Temperatures"           
## [767] "Light Snowfall"                 "Freezing Drizzle"              
## [769] "Gusty wind/rain"                "GUSTY WIND/HVY RAIN"           
## [771] "Blowing Snow"                   "Early snowfall"                
## [773] "Monthly Snowfall"               "Record Heat"                   
## [775] "Seasonal Snowfall"              "Monthly Rainfall"              
## [777] "Cold Temperature"               "Sml Stream Fld"                
## [779] "Heat Wave"                      "MUDSLIDE/LANDSLIDE"            
## [781] "Saharan Dust"                   "Volcanic Ash"                  
## [783] "Volcanic Ash Plume"             "Thundersnow shower"            
## [785] "NONE"                           "COLD AND SNOW"                 
## [787] "DAM BREAK"                      "TSTM WIND (G45)"               
## [789] "SLEET/FREEZING RAIN"            "BLACK ICE"                     
## [791] "BLOW-OUT TIDES"                 "UNSEASONABLY COOL"             
## [793] "TSTM HEAVY RAIN"                "Gusty Winds"                   
## [795] "GUSTY WIND"                     "TSTM WIND 40"                  
## [797] "TSTM WIND 45"                   "TSTM WIND (41)"                
## [799] "TSTM WIND (G40)"                "TSTM WND"                      
## [801] "Wintry mix"                     " TSTM WIND"                    
## [803] "Frost"                          "Frost/Freeze"                  
## [805] "RAIN (HEAVY)"                   "Record Warmth"                 
## [807] "Prolong Cold"                   "Cold and Frost"                
## [809] "URBAN/SML STREAM FLDG"          "STRONG WIND GUST"              
## [811] "LATE FREEZE"                    "BLOW-OUT TIDE"                 
## [813] "Hypothermia/Exposure"           "HYPOTHERMIA/EXPOSURE"          
## [815] "Lake Effect Snow"               "Mixed Precipitation"           
## [817] "Record High"                    "COASTALSTORM"                  
## [819] "Snow and sleet"                 "Freezing rain"                 
## [821] "Gusty winds"                    "Blizzard Summary"              
## [823] "SUMMARY OF MARCH 24-25"         "SUMMARY OF MARCH 27"           
## [825] "SUMMARY OF MARCH 29"            "GRADIENT WIND"                 
## [827] "Icestorm/Blizzard"              "Flood/Strong Wind"             
## [829] "TSTM WIND AND LIGHTNING"        "gradient wind"                 
## [831] "Freezing drizzle"               "Mountain Snows"                
## [833] "URBAN/SMALL STRM FLDG"          "Heavy surf and wind"           
## [835] "Mild and Dry Pattern"           "COLD AND FROST"                
## [837] "TYPHOON"                        "HIGH SWELLS"                   
## [839] "HIGH  SWELLS"                   "VOLCANIC ASH"                  
## [841] "DRY SPELL"                      " LIGHTNING"                    
## [843] "BEACH EROSION"                  "UNSEASONAL RAIN"               
## [845] "EARLY RAIN"                     "PROLONGED RAIN"                
## [847] "WINTERY MIX"                    "COASTAL FLOODING/EROSION"      
## [849] "HOT SPELL"                      "UNSEASONABLY HOT"              
## [851] " TSTM WIND (G45)"               "TSTM WIND  (G45)"              
## [853] "HIGH WIND (G40)"                "TSTM WIND (G35)"               
## [855] "DRY WEATHER"                    "ABNORMAL WARMTH"               
## [857] "UNUSUAL WARMTH"                 "WAKE LOW WIND"                 
## [859] "MONTHLY RAINFALL"               "COLD TEMPERATURES"             
## [861] "COLD WIND CHILL TEMPERATURES"   "MODERATE SNOW"                 
## [863] "MODERATE SNOWFALL"              "URBAN/STREET FLOODING"         
## [865] "COASTAL EROSION"                "UNUSUAL/RECORD WARMTH"         
## [867] "BITTER WIND CHILL"              "BITTER WIND CHILL TEMPERATURES"
## [869] "SEICHE"                         "TSTM"                          
## [871] "COASTAL  FLOODING/EROSION"      "UNSEASONABLY WARM YEAR"        
## [873] "HYPERTHERMIA/EXPOSURE"          "ROCK SLIDE"                    
## [875] "ICE PELLETS"                    "PATCHY DENSE FOG"              
## [877] "RECORD COOL"                    "RECORD WARM"                   
## [879] "HOT WEATHER"                    "RECORD TEMPERATURE"            
## [881] "TROPICAL DEPRESSION"            "VOLCANIC ERUPTION"             
## [883] "COOL SPELL"                     "WIND ADVISORY"                 
## [885] "GUSTY WIND/HAIL"                "RED FLAG FIRE WX"              
## [887] "FIRST FROST"                    "EXCESSIVELY DRY"               
## [889] "SNOW AND SLEET"                 "LIGHT SNOW/FREEZING PRECIP"    
## [891] "VOG"                            "MONTHLY PRECIPITATION"         
## [893] "MONTHLY TEMPERATURE"            "RECORD DRYNESS"                
## [895] "EXTREME WINDCHILL TEMPERATURES" "MIXED PRECIPITATION"           
## [897] "DRY CONDITIONS"                 "REMNANTS OF FLOYD"             
## [899] "EARLY SNOWFALL"                 "FREEZING FOG"                  
## [901] "LANDSPOUT"                      "DRIEST MONTH"                  
## [903] "RECORD  COLD"                   "LATE SEASON HAIL"              
## [905] "EXCESSIVE SNOW"                 "DRYNESS"                       
## [907] "FLOOD/FLASH/FLOOD"              "WIND AND WAVE"                 
## [909] "LIGHT FREEZING RAIN"            " WIND"                         
## [911] "MONTHLY SNOWFALL"               "RECORD PRECIPITATION"          
## [913] "ICE ROADS"                      "ROUGH SEAS"                    
## [915] "UNSEASONABLY WARM/WET"          "UNSEASONABLY COOL & WET"       
## [917] "UNUSUALLY WARM"                 "TSTM WIND G45"                 
## [919] "NON SEVERE HAIL"                "NON-SEVERE WIND DAMAGE"        
## [921] "UNUSUALLY COLD"                 "WARM WEATHER"                  
## [923] "LANDSLUMP"                      "THUNDERSTORM WIND (G40)"       
## [925] "UNSEASONABLY WARM & WET"        " FLASH FLOOD"                  
## [927] "LOCALLY HEAVY RAIN"             "WIND GUSTS"                    
## [929] "UNSEASONAL LOW TEMP"            "HIGH SURF ADVISORY"            
## [931] "LATE SEASON SNOW"               "GUSTY LAKE WIND"               
## [933] "ABNORMALLY DRY"                 "WINTER WEATHER MIX"            
## [935] "RED FLAG CRITERIA"              "WND"                           
## [937] "CSTL FLOODING/EROSION"          "SMOKE"                         
## [939] " WATERSPOUT"                    "SNOW ADVISORY"                 
## [941] "EXTREMELY WET"                  "UNUSUALLY LATE SNOW"           
## [943] "VERY DRY"                       "RECORD LOW RAINFALL"           
## [945] "ROGUE WAVE"                     "PROLONG WARMTH"                
## [947] "ACCUMULATED SNOWFALL"           "FALLING SNOW/ICE"              
## [949] "DUST DEVEL"                     "NON-TSTM WIND"                 
## [951] "NON TSTM WIND"                  "GUSTY THUNDERSTORM WINDS"      
## [953] "PATCHY ICE"                     "HEAVY RAIN EFFECTS"            
## [955] "EXCESSIVE HEAT/DROUGHT"         "NORTHERN LIGHTS"               
## [957] "MARINE TSTM WIND"               "   HIGH SURF ADVISORY"         
## [959] "HAZARDOUS SURF"                 "FROST/FREEZE"                  
## [961] "WINTER WEATHER/MIX"             "ASTRONOMICAL HIGH TIDE"        
## [963] "WHIRLWIND"                      "VERY WARM"                     
## [965] "ABNORMALLY WET"                 "TORNADO DEBRIS"                
## [967] "EXTREME COLD/WIND CHILL"        "ICE ON ROAD"                   
## [969] "DROWNING"                       "GUSTY THUNDERSTORM WIND"       
## [971] "MARINE HAIL"                    "HIGH SURF ADVISORIES"          
## [973] "HURRICANE/TYPHOON"              "HEAVY SURF/HIGH SURF"          
## [975] "SLEET STORM"                    "STORM SURGE/TIDE"              
## [977] "COLD/WIND CHILL"                "MARINE HIGH WIND"              
## [979] "TSUNAMI"                        "DENSE SMOKE"                   
## [981] "LAKESHORE FLOOD"                "MARINE THUNDERSTORM WIND"      
## [983] "MARINE STRONG WIND"             "ASTRONOMICAL LOW TIDE"         
## [985] "VOLCANIC ASHFALL"

Differences in formatting and capitalization, and misspellings of severe weather events can cause entries that describe the same or similar events to be counted as separate severe weather events.

The following lines of code duplicate the column ‘EVTYPE’ as ‘EVTYPE_CLEANED’ to retain the original severe weather events in ‘EVTYPE’, whereas the duplicated severe weather events in ‘EVTYPE_CLEANED’ will be cleaned to standardize formatting and capitalization, and correct misspellings.

The following transformations will standardize the capitalization, replace selected punctuations with whitespaces, and trim leading, trailing, and repeated whitespaces.

# Duplicate the EVTYPE column
storm_data$EVTYPE_CLEANED <- storm_data$EVTYPE

# Capitalize all letters for each event type
storm_data$EVTYPE_CLEANED <- toupper(storm_data$EVTYPE_CLEANED)

# Replace commas, periods, forward slashes,
# backslashes, and hyphens with spaces
storm_data <- storm_data %>%
  mutate(EVTYPE_CLEANED = str_replace_all(EVTYPE_CLEANED, ',', ' '))
storm_data <- storm_data %>%
  mutate(EVTYPE_CLEANED = str_replace_all(EVTYPE_CLEANED, '\\.', ' '))
storm_data <- storm_data %>%
  mutate(EVTYPE_CLEANED = str_replace_all(EVTYPE_CLEANED, '/', ' '))
storm_data <- storm_data %>%
  mutate(EVTYPE_CLEANED = str_replace_all(EVTYPE_CLEANED, '\\\\', ' '))
storm_data <- storm_data %>%
  mutate(EVTYPE_CLEANED = str_replace_all(EVTYPE_CLEANED, '-', ' '))

# Then remove extra leading and trailing whitespaces,
# and multiple consecutive whitespaces between words
storm_data <- storm_data %>%
  mutate(EVTYPE_CLEANED = str_squish(EVTYPE_CLEANED))

Correct misspellings

The following lines of code utilize the library hunspell to identify any words across the severe weather event entries that are not in a standard English dictionary and to replace it with the first suggested correct spelling, if there are any suggestions for correct spellings.

# Extract unique severe weather event entries
unique_evtypes <- c(unique(storm_data$EVTYPE_CLEANED))

# Identify any words that are not in a standard English dictionary
misspelled_evtypes <- hunspell_find(unique_evtypes)
unique_misspelled_evtypes <- unique(unlist(misspelled_evtypes))

# Generate spelling suggestions for each of these misspelled words
suggestions <- hunspell_suggest(unique_misspelled_evtypes)

# Select the first spelling suggestion for each word, or
# assign NA, if there are no spelling suggestions
top_suggestion <- sapply(suggestions, function(x) if (length(x) > 0) x[1] else NA_character_)

# Identify any words for with assigned spelling suggestions 
valid_idx <- !is.na(top_suggestion)

# Create a lookup table containing each misspelled word and its
# suggested replacement, if there was a suggestion available
lookup_table <- setNames(top_suggestion[valid_idx], unique_misspelled_evtypes[valid_idx])

# Define a function that replaces each misspelled word with its
# suggested replacement, if there was a suggestion avaialable
replace_misspellings <- function(text, lookup) {
  
  for (misspelled in names(lookup)) {
    pattern <- paste0("\\b", misspelled, "\\b")
    text <- gsub(pattern, lookup[misspelled], text, perl = TRUE)
  }
  
  return(text)
}

# Apply the function to the cleaned severe weather event entries
storm_data$EVTYPE_CLEANED <- replace_misspellings(storm_data$EVTYPE_CLEANED, lookup_table)

Consolidate similar severe weather event entries

The following lines of code print how often each unique word occurs across the cleaned severe weather event entries in descending order.

# Split the cleaned severe weather events into individual words, reduce words
# to their root forms by utilizing the hunspell_stem function, capitalize each
# letter of the resulting individual words, and store them in a data frame
single_words_evtypes <- data.frame(words = toupper(unlist(hunspell_stem(unlist(strsplit(storm_data$EVTYPE_CLEANED, split = " "))))))

# Count the frequency of each word across severe weather event entries
word_counts <- single_words_evtypes %>%
  count(words, sort = TRUE)

# Display the word frequency table
print(word_counts)
##             words      n
## 1            WIND 364679
## 2            HAIL 290396
## 3          UTMOST 227235
## 4    THUNDERSTORM 109588
## 5           FLOOD  83395
## 6         TORNADO  60698
## 7           FLASH  55677
## 8            SNOW  35179
## 9           HEAVY  27983
## 10         MARINE  25230
## 11           HIGH  23069
## 12         WINTER  19604
## 13      LIGHTNING  15777
## 14          STORM  15037
## 15           RAIN  12201
## 16        WEATHER   8171
## 17          URBAN   7660
## 18         STRONG   7652
## 19         FUNNEL   6991
## 20          CLOUD   6947
## 21             FL   6788
## 22            ICE   4390
## 23     WATERSPOUT   3862
## 24         STREAM   3480
## 25             ML   3395
## 26         FOREST   2918
## 27          FROST   2826
## 28       WILDFIRE   2769
## 29       BLIZZARD   2745
## 30           HEAT   2648
## 31        DROUGHT   2512
## 32           COLD   2463
## 33        EXTREME   1923
## 34            FOG   1883
## 35         FREEZE   1854
## 36      EXCESSIVE   1736
## 37         EXCESS   1735
## 38          CHILL   1584
## 39            RIP   1554
## 40           FIRE   1471
## 41           WILD   1462
## 42          DENSE   1306
## 43           SURF   1294
## 44            MIX   1264
## 45        COASTAL    866
## 46           TIDE    857
## 47       TROPICAL    757
## 48           LAKE    709
## 49         EFFECT    660
## 50      LANDSLIDE    613
## 51           DUST    589
## 52        CURRENT    470
## 53           CORD    449
## 54          SURGE    411
## 55      AVALANCHE    387
## 56           WARM    327
## 57       CURRENTS    307
## 58            DRY    305
## 59      HURRICANE    288
## 60          SMALL    284
## 61   ASTRONOMICAL    277
## 62     SEASONABLY    266
## 63      WINDCHILL    223
## 64          BURST    222
## 65          MICRO    217
## 66          LIGHT    211
## 67            RIV    205
## 68          RIVER    205
## 69            LOW    194
## 70         WARMTH    174
## 71           WAVE    169
## 72          DEVIL    150
## 73            AND    139
## 74       SNOWFALL    126
## 75          SLEET    122
## 76    TEMPERATURE    118
## 77       MODERATE    102
## 78          GUSTY    101
## 79        TYPHOON     99
## 80         WINTRY     94
## 81         SQUALL     90
## 82    PRECIPITATE     84
## 83  PRECIPITATION     84
## 84        SUMMARY     70
## 85          MONTH     61
## 86     DEPRESSION     60
## 87        MONTHLY     55
## 88         SEVERE     54
## 89          OTHER     52
## 90         DAMAGE     50
## 91             OF     50
## 92          MIXED     47
## 93            WET     47
## 94          GLAZE     46
## 95       RAINFALL     38
## 96           BLOW     37
## 97           ROAD     35
## 98            ICY     33
## 99           LONG     31
## 100      VOLCANIC     29
## 101      MUDSLIDE     28
## 102         TIDAL     28
## 103           ASH     27
## 104           MAY     26
## 105       DRIZZLE     25
## 106         USUAL     25
## 107        AUGUST     24
## 108          WALL     24
## 109         SHORE     23
## 110        CHEESE     21
## 111          COOL     21
## 112         SMOKE     21
## 113          OPAL     20
## 114       TSUNAMI     20
## 115             0     19
## 116      ADVISORY     19
## 117           HOT     18
## 118          JUNE     18
## 119         BLACK     17
## 120      GRADIENT     17
## 121         BEACH     16
## 122       EROSION     16
## 123           JAM     15
## 124           SEA     15
## 125           EAR     14
## 126         EARLY     14
## 127         MARCH     14
## 128             1     12
## 129         SLIDE     12
## 130           NON     11
## 131        PRECIS     11
## 132          SHOW     11
## 133         FIRST     10
## 134           MUD     10
## 135        STREET     10
## 136         SWELL     10
## 137            AM      9
## 138          LATE      9
## 139           MPH      9
## 140            PM      9
## 141           CHI      8
## 142     CONDITION      8
## 143           CST      8
## 144   HYPOTHERMIA      8
## 145          LAND      8
## 146         WATER      8
## 147      ABNORMAL      7
## 148           AIR      7
## 149         APRIL      7
## 150          ERIN      7
## 151      EXPOSURE      7
## 152       GUSTAVO      7
## 153          HARD      7
## 154          JULY      7
## 155         ROUGH      7
## 156         SPELL      7
## 157    ACCUMULATE      6
## 158  AGRICULTURAL      6
## 159          FLAG      6
## 160         MAJOR      6
## 161       PATTERN      6
## 162          ROCK      6
## 163          TREE      6
## 164          YEAR      6
## 165             3      5
## 166        BITTER      5
## 167           DAM      5
## 168          FALL      5
## 169          FROM      5
## 170          GUST      5
## 171          MELT      5
## 172         MINOR      5
## 173        NORMAL      5
## 174        ROTATE      5
## 175        SEASON      5
## 176    SEASONABLE      5
## 177     SEPTEMBER      5
## 178             6      4
## 179         BREAK      4
## 180         BRUSH      4
## 181            CH      4
## 182          DEAN      4
## 183          DOWN      4
## 184             G      4
## 185     HAILSTORM      4
## 186        PATCHY      4
## 187            RE      4
## 188           RED      4
## 189       SAHARAN      4
## 190        SHOWER      4
## 191          WAKE      4
## 192             2      3
## 193             4      3
## 194          CLOY      3
## 195       DRYNESS      3
## 196        FLURRY      3
## 197      GENERATE      3
## 198           HEY      3
## 199         JERRY      3
## 200         LOCAL      3
## 201          MILD      3
## 202           NOV      3
## 203         SPOUT      3
## 204          TEMP      3
## 205     TORNADOES      3
## 206          VERY      3
## 207     WHIRLWIND      3
## 208             7      2
## 209             9      2
## 210  ACCUMULATION      2
## 211            AN      2
## 212         BELOW      2
## 213    CLOUDBURST      2
## 214      CRITERIA      2
## 215       EDUARDO      2
## 216           END      2
## 217      ERUPTION      2
## 218            EX      2
## 219         FELIX      2
## 220          FLOE      2
## 221         FLOYD      2
## 222        GORDON      2
## 223         GRASS      2
## 224        GROUND      2
## 225           IND      2
## 226        MISHAP      2
## 227            NO      2
## 228          NONE      2
## 229            ON      2
## 230           OUT      2
## 231       REMNANT      2
## 232         RURAL      2
## 233          SEPT      2
## 234         SLUMP      2
## 235           SON      2
## 236     SOUTHEAST      2
## 237       THUNDER      2
## 238    TORRENTIAL      2
## 239             W      2
## 240           WIN      2
## 241           3RD      1
## 242             5      1
## 243      ACCIDENT      1
## 244       ALBERTO      1
## 245         ALOFT      1
## 246        APACHE      1
## 247           AWN      1
## 248        AWNING      1
## 249       BREAKUP      1
## 250        COUNTY      1
## 251        DEBRIS      1
## 252          DEEP      1
## 253         DRIFT      1
## 254         DROWN      1
## 255      DROWNING      1
## 256         EMILY      1
## 257            EN      1
## 258        EXTEND      1
## 259       FAILURE      1
## 260         FORCE      1
## 261           GOV      1
## 262     HAZARDOUS      1
## 263       HIGHWAY      1
## 264           JAN      1
## 265          JURY      1
## 266          LACK      1
## 267         LARGE      1
## 268            LE      1
## 269         METRO      1
## 270      MOUNTAIN      1
## 271      NAUSEOUS      1
## 272          NEAR      1
## 273      NORTHERN      1
## 274           OCT      1
## 275       OCTOBER      1
## 276          PACK      1
## 277        PELLET      1
## 278         PLUME      1
## 279            RA      1
## 280     RAINSTORM      1
## 281         RAPID      1
## 282          RISE      1
## 283        RISING      1
## 284         ROGUE      1
## 285         ROSIN      1
## 286      SEASONAL      1
## 287     SNOWSTORM      1
## 288         SPRAY      1
## 289          STEM      1
## 290            TO      1
## 291        TSWANA      1
## 292    TURBULENCE      1
## 293       VALANCE      1
## 294         WATCH      1
## 295       WETNESS      1
## 296            WI      1

I then manually defined a list of words that contains any weather-related words with more than 100 occurences as well as ‘TYPHOON’. The weather event ‘TYPHOON’ only had 99 occurences, but typhoons are the same as hurricanes and the weather event ‘HURRICANE’ had more than 100 occurences. Any weather event coded as ‘TYPHOON’ will be re-coded to ‘HURRICANE’ later on.

I then proceed through the list in descending order of occurences of each weather-related words. For each cleaned severe weather event entry that contains a match for the currently assessed weather-related word, I replace the severe weather event entry with the currently assessed weather-related word. This consolidates similar severe weather event entries into the same category of severe weather events.

The last lines of the following code re-codes any weather event coded as ‘TYPHOON’ to ‘HURRICANE’.

# Manually define a list of words that contains any weather-related
# words with more than 100 occurences as well as 'TYPHOON'
most_common_events <- c(
  "WIND", "HAIL", "THUNDERSTORM", "FLOOD", "TORNADO",
  "SNOW", "WINTER", "LIGHTNING", "STORM", "RAIN",
  "FUNNEL", "ICE", "WATERSPOUT", "STREAM", "FROST",
  "WILDFIRE", "BLIZZARD", "HEAT", "DROUGHT", "COLD",
  "FOG", "FREEZE", "FIRE", "SURF", "TIDE",
  "LANDSLIDE", "DUST", "CURRENT", "SURGE", "AVALANCHE", 
  "WARM", "DRY", "HURRICANE", "WINDCHILL", "WAVE",
  "SNOWFALL", "SLEET", "TEMPERATURE", "TYPHOON"
)

# Loop through each commonly occurring weather-related word.
for (e in seq_along(most_common_events)) {
  
  # Construct a regular expression that searches for the specified word
  # anywhere within an event classification.
  # \\w* allows for zero or more word characters before and after the term.
  # This allows variations such as "HIGH WINDS" and "STRONG WIND"
  # to be identified as containing the common term WIND.
  pattern <- paste0("\\w*", most_common_events[e], "\\w*")
  
  # Check whether each event classification contains the current
  # commonly occurring weather-related word.
  #
  # If a match is found, replace the entire event classification
  # with the corresponding standardized term.
  # If no match is found, retain the original event classification.
  #
  # Note that classifications containing multiple terms may be
  # reassigned more than once as the loop progresses.
  storm_data <- storm_data %>%
    mutate(EVTYPE_CLEANED = if_else(str_detect(EVTYPE_CLEANED, pattern),most_common_events[e],EVTYPE_CLEANED))
}

# Standardize all TYPHOON classifications as HURRICANE.
# This combines the two equivalent tropical cyclone classifications
# into one category for the subsequent analysis.
storm_data <- storm_data %>%
  mutate(EVTYPE_CLEANED = str_replace_all(EVTYPE_CLEANED, 'TYPHOON', 'HURRICANE'))

To determine whether consolidation of the severe weather types was successful, the following lines of code print how often each unique severe weather event tyoe occurs across the cleaned and consolidated severe weather event entries in descending order.

# Split the cleaned severe weather events into individual words, reduce words
# to their root forms by utilizing the hunspell_stem function, capitalize each
# letter of the resulting individual words, and store them in a data frame
cleaned_evtypes <- data.frame(words = storm_data$EVTYPE_CLEANED)

# Count the frequency of each word across severe weather event entries
word_counts <- cleaned_evtypes %>%
  count(words, sort = TRUE)

# Display the word frequency table
print(word_counts)
##                             words      n
## 1                            WIND 364901
## 2                            HAIL 289277
## 3                           FLOOD  82712
## 4                         TORNADO  60700
## 5                          WINTER  19597
## 6                            SNOW  17677
## 7                       LIGHTNING  15764
## 8                            RAIN  12152
## 9                          FUNNEL   6987
## 10                           FIRE   4239
## 11                     WATERSPOUT   3847
## 12                          STORM   3662
## 13                         STREAM   3408
## 14                       BLIZZARD   2723
## 15                           HEAT   2648
## 16                        DROUGHT   2488
## 17                            FOG   1880
## 18                          FROST   1413
## 19                           SURF   1063
## 20                           COLD    884
## 21                        CURRENT    774
## 22                      LANDSLIDE    609
## 23                      AVALANCHE    386
## 24                           WARM    327
## 25                      HURRICANE    298
## 26                            DRY    287
## 27                           TIDE    281
## 28                           DUST    158
## 29                         FREEZE     99
## 30                     WINTRY MIX     94
## 31                            ICE     92
## 32                    TEMPERATURE     83
## 33            TROPICAL DEPRESSION     60
## 34                          SLEET     59
## 35                          OTHER     52
## 36                          GLAZE     43
## 37            MIXED PRECIPITATION     37
## 38          MONTHLY PRECIPITATION     36
## 39                      ICY ROADS     32
## 40               FREEZING DRIZZLE     24
## 41                   VOLCANIC ASH     23
## 42                         CHEESE     21
## 43                        TSUNAMI     20
## 44               UNSEASONABLY WET     19
## 45                       MUDSLIDE     17
## 46              UNSEASONABLY COOL     12
## 47                          SMOKE     11
## 48                    DENSE SMOKE     10
## 49                   MIXED PRECIS     10
## 50               UNSEASONABLY HOT     10
## 51                    MICRO BURST      9
## 52                      MUDSLIDES      9
## 53                      HEAVY MIX      8
## 54                      HIGH SEAS      8
## 55           HYPOTHERMIA EXPOSURE      7
## 56                      MUD SLIDE      7
## 57                    RECORD HIGH      7
## 58                        GUSTAVO      6
## 59                    HIGH SWELLS      6
## 60                     HIGH WATER      6
## 61                WET MICRO BURST      6
## 62                    RECORD COOL      5
## 63            ROTATING WALL CLOUD      5
## 64                     WALL CLOUD      5
## 65                  BEACH EROSION      4
## 66                      DAM BREAK      4
## 67            HEAVY PRECIPITATION      4
## 68                     RECORD LOW      4
## 69                           WAVE      4
## 70                      WET MONTH      4
## 71                       WET YEAR      4
## 72                       LIGHTING      3
## 73           NORMAL PRECIPITATION      3
## 74                     ROUGH SEAS      3
## 75                    URBAN SMALL      3
## 76              VOLCANIC ASH FALL      3
## 77     BELOW NORMAL PRECIPITATION      2
## 78                     DOWN BURST      2
## 79                     HEAVY SEAS      2
## 80                   HEAVY SHOWER      2
## 81                      HOT SPELL      2
## 82                     LAND SLUMP      2
## 83                     LAND SPOUT      2
## 84                  MARINE MISHAP      2
## 85                           NONE      2
## 86              RED FLAG CRITERIA      2
## 87              REMNANTS OF FLOYD      2
## 88                     ROCK SLIDE      2
## 89              SUMMARY AUGUST 10      2
## 90              SUMMARY AUGUST 11      2
## 91            SUMMARY OF APRIL 12      2
## 92            SUMMARY OF APRIL 21      2
## 93             SUMMARY OF JUNE 13      2
## 94              SUMMARY OF JUNE 3      2
## 95            SUMMARY OF MARCH 23      2
## 96           SUMMARY SEPTEMBER 23      2
## 97                SUMMARY: NOV 16      2
## 98                          SURGE      2
## 99          UNSEASONABLE LOW TEMP      2
## 100       UNSEASONABLY COOL & WET      2
## 101               URBAN AND SMALL      2
## 102             VOLCANIC ERUPTION      2
## 103                             ?      1
## 104                ABNORMALLY WET      1
## 105                 APACHE COUNTY      1
## 106                   BEACH ROSIN      1
## 107               COASTAL EROSION      1
## 108                  COOL AND WET      1
## 109                    COOL SPELL      1
## 110                   DAM FAILURE      1
## 111                  DRIEST MONTH      1
## 112                      DROWNING      1
## 113                           END      1
## 114                     EXCESSIVE      1
## 115       EXCESSIVE PRECIPITATION      1
## 116             EXCESSIVE WETNESS      1
## 117                 EXTREMELY WET      1
## 118 FREEZING DRIZZLE AND FREEZING      1
## 119                FREEZING SPRAY      1
## 120                           GOV      1
## 121                   GUSTAVO AND      1
## 122                 HEAVY SHOWERS      1
## 123                  HEAVY SWELLS      1
## 124                          HIGH      1
## 125                   HOT PATTERN      1
## 126                   HOT WEATHER      1
## 127                   HYPOTHERMIA      1
## 128              LARGE WALL CLOUD      1
## 129               MARINE ACCIDENT      1
## 130                  MILD PATTERN      1
## 131                MUD ROCK SLIDE      1
## 132                    MUD SLIDES      1
## 133             NO SEVERE WEATHER      1
## 134               NORTHERN LIGHTS      1
## 135          RAPIDLY RISING WATER      1
## 136          RECORD PRECIPITATION      1
## 137             SEVERE TURBULENCE      1
## 138                     SOUTHEAST      1
## 139             SUMMARY AUGUST 17      1
## 140            SUMMARY AUGUST 2 3      1
## 141             SUMMARY AUGUST 21      1
## 142             SUMMARY AUGUST 28      1
## 143              SUMMARY AUGUST 4      1
## 144              SUMMARY AUGUST 7      1
## 145              SUMMARY AUGUST 9      1
## 146                SUMMARY JAN 17      1
## 147            SUMMARY JULY 23 24      1
## 148            SUMMARY JUNE 18 19      1
## 149              SUMMARY JUNE 5 6      1
## 150                SUMMARY JUNE 6      1
## 151           SUMMARY OF APRIL 13      1
## 152           SUMMARY OF APRIL 27      1
## 153          SUMMARY OF APRIL 3RD      1
## 154           SUMMARY OF AUGUST 1      1
## 155            SUMMARY OF JULY 11      1
## 156             SUMMARY OF JULY 2      1
## 157            SUMMARY OF JULY 22      1
## 158            SUMMARY OF JULY 26      1
## 159            SUMMARY OF JULY 29      1
## 160             SUMMARY OF JULY 3      1
## 161            SUMMARY OF JUNE 10      1
## 162            SUMMARY OF JUNE 11      1
## 163            SUMMARY OF JUNE 12      1
## 164            SUMMARY OF JUNE 15      1
## 165            SUMMARY OF JUNE 16      1
## 166            SUMMARY OF JUNE 18      1
## 167            SUMMARY OF JUNE 23      1
## 168            SUMMARY OF JUNE 24      1
## 169            SUMMARY OF JUNE 30      1
## 170             SUMMARY OF JUNE 4      1
## 171             SUMMARY OF JUNE 6      1
## 172           SUMMARY OF MARCH 14      1
## 173           SUMMARY OF MARCH 24      1
## 174        SUMMARY OF MARCH 24 25      1
## 175           SUMMARY OF MARCH 27      1
## 176           SUMMARY OF MARCH 29      1
## 177             SUMMARY OF MAY 10      1
## 178             SUMMARY OF MAY 13      1
## 179             SUMMARY OF MAY 14      1
## 180             SUMMARY OF MAY 22      1
## 181          SUMMARY OF MAY 22 AM      1
## 182          SUMMARY OF MAY 22 PM      1
## 183          SUMMARY OF MAY 26 AM      1
## 184          SUMMARY OF MAY 26 PM      1
## 185          SUMMARY OF MAY 31 AM      1
## 186          SUMMARY OF MAY 31 PM      1
## 187           SUMMARY OF MAY 9 10      1
## 188            SUMMARY SEPT 25 26      1
## 189          SUMMARY SEPTEMBER 20      1
## 190           SUMMARY SEPTEMBER 3      1
## 191           SUMMARY SEPTEMBER 4      1
## 192              SUMMARY: NOV 6 7      1
## 193            SUMMARY: OCT 20 21      1
## 194           SUMMARY: OCTOBER 31      1
## 195              SUMMARY: SEPT 18      1
## 196                        TSWANA      1
## 197         URBAN SMALL STEM FLAG      1
## 198                        UTMOST      1
## 199                    UTMOST END      1
## 200                       VALANCE      1
## 201            VOLCANIC ASH PLUME      1
## 202                   WATER SPOUT      1
## 203                WET CLOUDBURST      1
## 204                   WET WEATHER      1

Quantifying missing population health and economic data

The following lines of code quantify the number of missing entries for fatalities and injuries. No severe weather events are missing entries for fatalities or injuries. Therefore, no additional data cleaning is necessary before determining which severe weather events have the largest impact on population health.

# Quantify missing values in the FATALITIES column
sum(is.na(storm_data$FATALITIES))
## [1] 0
# Quantify missing values in the INJURIES column
sum(is.na(storm_data$INJURIES))
## [1] 0

The following lines of code quantify the number of missing entries for property and crop damages, and the number of non-standard or missing entries for the magnitude multipliers for property and crop damages in dollar amounts. Standard magnitude multipliers for property and crop damages are “H” for a multiplier of $100, “K” for a multiplier of $1,000, “M” for a multiplier of $1,000,000, and “B” for a multiplier of $1,000,000,000. To quantify the number of non-standard or missing magnitude multipliers for property and crop damages, I identified any entries that were not “H”, “K”, “M”, or “B” and calculated the sum of them. No severe weather event are missing entries for property or crop damage. However, 466256 or 51.67% of property damage magnitude multiplier entries are non-standard or missing, and 618462 or 68.54% of crop damage magnitude multiplier entries are non-standard or missing.

# Quantify missing values for property damage in the PROPDMG column
sum(is.na(storm_data$PROPDMG))
## [1] 0
# Quantify missing values for crop damage in the CROPDMG column
sum(is.na(storm_data$CROPDMG))
## [1] 0
# Quantify non-standard and missing values for property damage
# magnitude multipliers in the PROPDMGEXP column, and quantify
# the percentage of missing values
sum(!storm_data$PROPDMGEXP %in% c("H","K","M","B"))
## [1] 466256
sum(!storm_data$PROPDMGEXP %in% c("H","K","M","B")) / nrow(storm_data)
## [1] 0.5167434
# Quantify non-standard and missing values for property damage
# magnitude multipliers in the PROPDMGEXP column, and quantify
# the percentage of missing values
sum(!storm_data$CROPDMGEXP %in% c("H","K","M","B"))
## [1] 618462
sum(!storm_data$CROPDMGEXP %in% c("H","K","M","B")) / nrow(storm_data)
## [1] 0.6854306

Setting missing economic data to NA values

The following lines of code duplicate the property and crop damage columns and set any entries with a non-standard or missing magnitude multipliers to NA values, so that these entries can be excluded from later analyses. I decided not to infer values for these entries, since it is not possible for me to know whether entries were supposed to be “H”,“K”,“M”, or “B”. Once entries with a non-standard or missing magnitude multipliers were set to NA values, each duplicated property and crop damage is scaled to its total dollar amount based on its corresponding magnitude multiplier.

# Duplicate PROPDMG column, and set any entries with a
# non-standard or missing magnitude multipliers to NA values
storm_data$PROPDMG_MAG <- storm_data$PROPDMG
storm_data$PROPDMG_MAG <- ifelse(!storm_data$PROPDMG_MAG %in% c("H","K","M","B"), storm_data$PROPDMG_MAG, NA)

# Scale each duplicated property damage to its total dollar
# amount based on its corresponding magnitude multiplier
storm_data$PROPDMG_MAG[grepl("H", storm_data$PROPDMGEXP)] <-
  storm_data$PROPDMG_MAG[grepl("H", storm_data$PROPDMGEXP)] * 100
storm_data$PROPDMG_MAG[grepl("K", storm_data$PROPDMGEXP)] <-
  storm_data$PROPDMG_MAG[grepl("K", storm_data$PROPDMGEXP)] * 1000
storm_data$PROPDMG_MAG[grepl("M", storm_data$PROPDMGEXP)] <-
  storm_data$PROPDMG_MAG[grepl("M", storm_data$PROPDMGEXP)] * 1000000
storm_data$PROPDMG_MAG[grepl("B", storm_data$PROPDMGEXP)] <-
  storm_data$PROPDMG_MAG[grepl("B", storm_data$PROPDMGEXP)] * 1000000000

# Duplicate PROPDMG column, and set any entries with a
# non-standard or missing magnitude multipliers to NA values
storm_data$CROPDMG_MAG <- storm_data$PROPDMG
storm_data$CROPDMG_MAG <- ifelse(!storm_data$CROPDMG_MAG %in% c("H","K","M","B"), storm_data$CROPDMG_MAG, NA)

# Scale each duplicated property damage to its total dollar
# amount based on its corresponding magnitude multiplier
storm_data$CROPDMG_MAG[grepl("H", storm_data$CROPDMGEXP)] <-
  storm_data$CROPDMG_MAG[grepl("H", storm_data$CROPDMGEXP)] * 100
storm_data$CROPDMG_MAG[grepl("K", storm_data$CROPDMGEXP)] <-
  storm_data$CROPDMG_MAG[grepl("K", storm_data$CROPDMGEXP)] * 1000
storm_data$CROPDMG_MAG[grepl("M", storm_data$CROPDMGEXP)] <-
  storm_data$CROPDMG_MAG[grepl("M", storm_data$CROPDMGEXP)] * 1000000
storm_data$CROPDMG_MAG[grepl("B", storm_data$CROPDMGEXP)] <-
  storm_data$CROPDMG_MAG[grepl("B", storm_data$CROPDMGEXP)] * 1000000000

Results

Which severe weather events are most harmful to population health?

The following figure compares the 20 cleaned and consolidated severe weather events that result in the most fatalities and injuries in descending order. The two figure panels utilize separate rankings. Therefore, the position of a severe weather event does not necessarily remain the same between the fatalities and injuries panels.

# Calculate the total number of fatalities associated with each cleaned 
# and consolidated severe weather event, and exclude missing values
health_fatalities <- storm_data %>%
  group_by(EVTYPE_CLEANED) %>%
  summarise(fatalities = sum(FATALITIES, na.rm = TRUE))

# Calculate the total number of injuries associated with each cleaned 
# and consolidated severe weather event, and exclude missing values
health_injuries <- storm_data %>%
  group_by(EVTYPE_CLEANED) %>%
  summarise(injuries = sum(INJURIES, na.rm = TRUE))

# Sort the totals in descending order
health_fatalities <- arrange(health_fatalities, desc(fatalities))
health_injuries <- arrange(health_injuries, desc(injuries))

# Visualize the first 20 entries for fatalities and injuries using a scatter plot
p1 <- ggplot(data = head(health_fatalities, 20), aes(x = seq_along(fatalities), y = fatalities)) +
  geom_point() + scale_x_continuous(breaks = (1:20), labels = health_fatalities$EVTYPE_CLEANED[1:20]) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
  labs(x = "", y = "Fatalities")

p2 <- ggplot(data = head(health_injuries, 20), aes(x = seq_along(injuries), y = injuries)) +
  geom_point() + scale_x_continuous(breaks = (1:20), labels = health_injuries$EVTYPE_CLEANED[1:20]) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
  labs(x = "", y = "Injuries")

print(p1 + p2)

The figure panels show the total number of people, who died or were injured, for each of the 20 severe weather events with the most fatalities and injuries on their respective y-axes. Both fatalities and injuries are harmful to the population health. Although it is difficult to determine which is more harmful, it can be argued that dying has a more severe impact on a person’s life than being injured. The five cleaned and consolidated severe weather events with the largest number of fatalities are tornados, heat, floods, wind, and lightning. Likewise, the five cleaned and consolidated severe weather events with the largest number of injuries are tornados, wind, heat, flood, and lightning. Tornados cause both the most fatalities and injuries, and are therefore most harmful to population health. Heat, floods, wind, and lightning are the severe weather events that produce both the most fatalities and injuries after tornados, indicating that heat, floods, wind and lightning are the most harmful to population health after tornados.

Which severe weather events have the largest economic consequences?

The following figure compares the 20 cleaned and consolidated severe weather events that result in the largest property and crop damages in descending order. The two figure panels utilize separate rankings. Therefore, the position of a severe weather event does not necessarily remain the same between the property and crop damage panels.

# Calculate the total dollar amounts for property damages associated with each
# cleaned  and consolidated severe weather event, and exclude missing values
damage_property <- storm_data %>%
  group_by(EVTYPE_CLEANED) %>%
  summarise(property = sum(PROPDMG_MAG, na.rm = TRUE))

# Calculate the total dollar amounts for crop damages associated with each
# cleaned  and consolidated severe weather event, and exclude missing values
damage_crops <- storm_data %>%
  group_by(EVTYPE_CLEANED) %>%
  summarise(crops = sum(CROPDMG_MAG, na.rm = TRUE))

# Sort the totals in descending order
damage_property <- arrange(damage_property, desc(property))
damage_crops <- arrange(damage_crops, desc(crops))

# Visualize the first 20 entries for property and crop damages using a scatter plot
q1 <- ggplot(data = head(damage_property, 20), aes(x = seq_along(property), y = property)) +
  geom_point() + scale_x_continuous(breaks = (1:20), labels = damage_property$EVTYPE_CLEANED[1:20]) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
  labs(x = "", y = "Property damage")

q2 <- ggplot(data = head(damage_crops, 20), aes(x = seq_along(crops), y = crops)) +
  geom_point() + scale_x_continuous(breaks = (1:20), labels = damage_crops$EVTYPE_CLEANED[1:20]) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
  labs(x = "", y = "Crop damage")

print(q1 + q2)

The figure panels show the total dollar amounts for property and crop damages for each of the 20 severe weather events with the largest property and crop damages on their respective y-axes. Both property and crop damages have large economic consequences, and it is difficult to determine which has larger economic consequences. However, the top seven severe weather events that caused the largest property and crop damages are consistent, albeit with different orderings. The seven cleaned and consolidated severe weather events that caused the largest total dollar amounts for property damages are floods, hurricanes, storms, tornados, winds, hail and fire. The seven cleaned and consolidated severe weather events that caused the largest total dollar amounts for crop damages are storms, floods, hail, winds, hurricanes, tornados, and fire. Thus, the severe weather events that have the largest econmic consequences are floods, hurricanes, tornados, storms, winds, hail, and fire.