Introduction

Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern.

This project involves exploring the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. This database tracks characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of any fatalities, injuries, and property damage.

Data

The data for this assignment come in the form of a comma-separated-value file compressed via the bzip2 algorithm to reduce its size. You can download the file from the course web site:

StormData [47Mb] There is also some documentation of the database available. Here you will find how some of the variables are constructed/defined.

National Weather Service Storm Data Documentation

National Climatic Data Center Storm Events FAQ

The events in the database start in the year 1950 and end in November 2011. In the earlier years of the database there are generally fewer events recorded, most likely due to a lack of good records. More recent years should be considered more complete.

Assignment

The basic goal of this assignment is to explore the NOAA Storm Database and answer some basic questions about severe weather events. You must use the database to answer the questions below and show the code for your entire analysis. Your analysis can consist of tables, figures, or other summaries. You may use any R package you want to support your analysis.

Questions

Your data analysis must address the following questions:

Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to popuulation health?

Across the United States, which types of events have the greatest economic consequences?

Consider writing your report as if it were to be read by a government or municipal manager who might be responsible for preparing for severe weather events and will need to prioritize resources for different types of events. However, there is no need to make any specific recommendations in your report.

Requirements

For this assignment you will need some specific tools

RStudio: You will need RStudio to publish your completed analysis document to RPubs. You can also use RStudio to edit/write your analysis.

knitr: You will need the knitr package in order to compile your R Markdown document and convert it to HTML

Document Layout

Language: Your document should be written in English.

Title: Your document should have a title that briefly summarizes your data analysis

Synopsis: Immediately after the title, there should be a synopsis which describes and summarizes your analysis in at most 10 complete sentences.

There should be a section titled Data Processing which describes (in words and code) how the data were loaded into R and processed for analysis. In particular, your analysis must start from the raw CSV file containing the data. You cannot do any preprocessing outside the document. If preprocessing is time- consuming you may consider using the cache = TRUE option for certain code chunks.

There should be a section titled Results in which your results are presented.

You may have other sections in your analysis, but Data Processing and Results are required.

The analysis document must have at least one figure containing a plot.

Your analyis must have no more than three figures. Figures may have multiple plots in them (i.e. panel plots), but there cannot be more than three figures total.

You must show all your code for the work in your analysis document. This may make the document a bit verbose, but that is okay. In general, you should ensure that echo = TRUE for every code chunk (this is the default setting in knitr).

Publishing Your Analysis

For this assignment you will need to publish your analysis on RPubs.com. If you do not already have an account, then you will have to create a new account. After you have completed writing your analysis in RStudio, you can publish it to RPubs by doing the following:

In RStudio, make sure your R Markdown document (.Rmd) document is loaded in the editor

Click the Knit HTML button in the doc toolbar to preview your document.

In the preview window, click the Publish button.

Once your document is published to RPubs, you should get a unique URL to that document. Make a note of this URL as you will need it to submit your assignment.

Submitting Your Assignment

In order to submit this assignment, you must copy the RPubs URL for your completed data analysis document in to the peer assessment question.

Comparison of states on outcomes from storms and other severe weather events

Synopsis

In order to compare outcomes from multiple weather types, The U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database

Data from 1193 to 2011 was used to determine the number of fatalities, injuries, and the amount in dollars of property damage was caused by various types of weather categories including convective, extreme temps, flooding, and various other types.

Illinois suffered the greatest number of fatalities due to extreme temperature events (998), Texas suffered the greatest number of injuries due to flooding (6,951), and the highest amount of property damage was reported by California ($117.4 Billion).

The following demonstrates these findings:

Data Processing

Load packages.

packages <- c("data.table", "ggplot2", "xtable", "downloader", "chron")
sapply(packages, require, character.only=TRUE, quietly=TRUE)
## data.table    ggplot2     xtable downloader      chron 
##       TRUE       TRUE       TRUE       TRUE       TRUE

Fix URL reading for knitr. See Stackoverflow.

setInternet2(TRUE)

Download and unzip files

Download the storm data documentation files.

url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fpeer2_doc%2Fpd01016005curr.pdf"
f <- file.path(getwd(), "StormDataDocumentation.pdf")
download.file(url, f, mode="wb")
url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fpeer2_doc%2FNCDC%20Storm%20Events-FAQ%20Page.pdf"
f <- file.path(getwd(), "StormEventsFAQ.pdf")
download.file(url, f, mode="wb")

Download the zipped storm data file.

url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
filep <- file.path(getwd(), "StormData.csv.bz2")
download.file(url, filep, mode="wb")

Unzip and read the data file.

Read the CSV file as a data frame

library(R.utils)
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.7.0 (2015-02-19) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.19.0 (2015-02-27) successfully loaded. See ?R.oo for help.
## 
## Attaching package: 'R.oo'
## 
## The following objects are masked from 'package:methods':
## 
##     getClasses, getMethods
## 
## The following objects are masked from 'package:base':
## 
##     attach, detach, gc, load, save
## 
## R.utils v2.1.0 (2015-05-27) successfully loaded. See ?R.utils for help.
## 
## Attaching package: 'R.utils'
## 
## The following object is masked from 'package:utils':
## 
##     timestamp
## 
## The following objects are masked from 'package:base':
## 
##     cat, commandArgs, getOption, inherits, isOpen, parse, warnings
bunzip2("StormData.csv.bz2", "StormData.csv", remove = FALSE, skip = TRUE)
## [1] "StormData.csv"
## attr(,"temporary")
## [1] FALSE
dataset <- read.csv("StormData.csv")
Storm <- data.table(dataset)
str(Storm)
## Classes 'data.table' and 'data.frame':   902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : Factor w/ 16335 levels "1/1/1966 0:00:00",..: 6523 6523 4242 11116 2224 2224 2260 383 3980 3980 ...
##  $ BGN_TIME  : Factor w/ 3608 levels "00:00:00 AM",..: 272 287 2705 1683 2584 3186 242 1683 3186 3186 ...
##  $ TIME_ZONE : Factor w/ 22 levels "ADT","AKS","AST",..: 7 7 7 7 7 7 7 7 7 7 ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: Factor w/ 29601 levels "","5NM E OF MACKINAC BRIDGE TO PRESQUE ISLE LT MI",..: 13513 1873 4598 10592 4372 10094 1973 23873 24418 4598 ...
##  $ STATE     : Factor w/ 72 levels "AK","AL","AM",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ EVTYPE    : Factor w/ 985 levels "   HIGH SURF ADVISORY",..: 834 834 834 834 834 834 834 834 834 834 ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : Factor w/ 35 levels "","  N"," NW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_LOCATI: Factor w/ 54429 levels "","- 1 N Albion",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_DATE  : Factor w/ 6663 levels "","1/1/1993 0:00:00",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_TIME  : Factor w/ 3647 levels ""," 0900CST",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : Factor w/ 24 levels "","E","ENE","ESE",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_LOCATI: Factor w/ 34506 levels "","- .5 NNW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: Factor w/ 19 levels "","-","?","+",..: 17 17 17 17 17 17 17 17 17 17 ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: Factor w/ 9 levels "","?","0","2",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ WFO       : Factor w/ 542 levels ""," CI","$AC",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ STATEOFFIC: Factor w/ 250 levels "","ALABAMA, Central",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ ZONENAMES : Factor w/ 25112 levels "","                                                                                                                               "| __truncated__,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : Factor w/ 436774 levels "","-2 at Deer Park\n",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...
##  - attr(*, ".internal.selfref")=<externalptr>

Clean data

Rename the variables to lowercase for ease of coding.

old <- names(Storm)
new <- tolower(old)
setnames(Storm, old, new)

Convert the bgn_date character class variable to a date class variable.

bgn_date <- as.character(Storm$BGN_DATE)
bgn_date <- unlist(Storm$bgn_date)
bgn_date <- as.numeric(bgn_date)
bgn_date <- matrix(bgn_date, nrow=nrow(Storm), byrow=TRUE)

reformat the property damage variable into a new variable, propertyDamage.

  • If propdmgexp = B, then multiply propdmg by 1,000,000,000
  • Else if propdmgexp = M, then multiply propdmg by 1,000,000
  • Else if propdmgexp = K, then multiply propdmg by 1,000
  • Else if propdmgexp = H, then multiply propdmg by 100
  • Else leave propdmg as-is
Storm <- Storm[, propdmgexp := toupper(propdmgexp)]
Storm[, .N, propdmgexp]
##     propdmgexp      N
##  1:          K 424665
##  2:          M  11337
##  3:            465934
##  4:          B     40
##  5:          +      5
##  6:          0    216
##  7:          5     28
##  8:          6      4
##  9:          ?      8
## 10:          4      4
## 11:          2     13
## 12:          3      4
## 13:          H      7
## 14:          7      5
## 15:          -      1
## 16:          1     25
## 17:          8      1
Storm <- Storm[, propertyDamage := ifelse(propdmgexp == "B", propdmg * 1E9, ifelse(propdmgexp == "M", propdmg * 1E6, ifelse(propdmgexp == "K", propdmg * 1E3, ifelse(propdmgexp == "H", propdmg * 1E2, propdmg))))]
summary(Storm$propertyDamage)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.000e+00 0.000e+00 0.000e+00 4.736e+05 5.000e+02 1.150e+11

Reformat the crop damage variable into a new variable, cropDamage.

  • If cropdmgexp = B, then multiply cropdmg by 1,000,000,000
  • Else if cropdmgexp = M, then multiply cropdmg by 1,000,000
  • Else if cropdmgexp = K, then multiply cropdmg by 1,000
  • Else leave cropdmg as-is
Storm <- Storm[, cropdmgexp := toupper(cropdmgexp)]
Storm[, .N, cropdmgexp]
##    cropdmgexp      N
## 1:            618413
## 2:          M   1995
## 3:          K 281853
## 4:          B      9
## 5:          ?      7
## 6:          0     19
## 7:          2      1
Storm <- Storm[, cropDamage := ifelse(cropdmgexp == "B", cropdmg * 1E9, ifelse(cropdmgexp == "M", cropdmg * 1E6, ifelse(cropdmgexp == "K", cropdmg * 1E3, cropdmg)))]
summary(Storm$cropDamage)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.000e+00 0.000e+00 0.000e+00 5.442e+04 0.000e+00 5.000e+09

Group event types

List the number of unique values of evtype.

message(sprintf("Number of unique values of evtype: %.0d", length(unique(Storm$evtype))))
## Number of unique values of evtype: 985

Group event types as found in the 2009 Annual Summaries

evtype needs a lot of data cleaning.

Create indicator variables for event types that are most frequent and define a helper function freqtab to help with grouping evtype values.

indicator <- function (regex) {
    indicator <- grepl(regex, Storm$evtype, ignore.case=TRUE)
    uniqueEventTypes <- unique(Storm[indicator, evtype])
    show(uniqueEventTypes[order(uniqueEventTypes)])
    indicator
}

Create an indicators for variations of weather: Lightning, Tornado, Thunderstorm Wind, Hail, Cold, Heat, Flood, Rain,Snow, Ice, Freeze, and Winter Weather. List the event types that fall into groups of Convection, Extreme Temperatures, Flood, and Winter.

regexLightning <- "\\bL\\S+?G\\b"
regexTornado <- "(NADO)|(\\bTOR\\S+?O\\b|(\\bFUN))"
regexThunderstorm <- "THUNDERSTORM|TSTM"
regexWind <- "(WIND)|(WND)"
regexHail <- "HAIL"
regex <- paste(regexLightning, regexTornado, regexThunderstorm, regexWind, regexHail, sep="|")
Storm <- Storm[, eventConvection := indicator(regex)]
##   [1]  LIGHTNING                      TSTM WIND                    
##   [3]  TSTM WIND (G45)                WIND                         
##   [5] BITTER WIND CHILL              BITTER WIND CHILL TEMPERATURES
##   [7] BLIZZARD AND EXTREME WIND CHIL BLIZZARD/HIGH WIND            
##   [9] BLOWING SNOW- EXTREME WIND CHI BLOWING SNOW & EXTREME WIND CH
##  [11] BLOWING SNOW/EXTREME WIND CHIL COLD AIR FUNNEL               
##  [13] COLD AIR FUNNELS               COLD AIR TORNADO              
##  [15] COLD WIND CHILL TEMPERATURES   COLD/WIND CHILL               
##  [17] COLD/WINDS                     DEEP HAIL                     
##  [19] DOWNBURST WINDS                DRY MICROBURST WINDS          
##  [21] DRY MIRCOBURST WINDS           DUST STORM/HIGH WINDS         
##  [23] EXTREME COLD/WIND CHILL        EXTREME WIND CHILL            
##  [25] EXTREME WIND CHILL/BLOWING SNO EXTREME WIND CHILLS           
##  [27] EXTREME WINDCHILL              EXTREME WINDCHILL TEMPERATURES
##  [29] FLASH FLOOD WINDS              FLASH FLOODING/THUNDERSTORM WI
##  [31] FLOOD/RAIN/WIND                FLOOD/RAIN/WINDS              
##  [33] Flood/Strong Wind              FUNNEL                        
##  [35] Funnel Cloud                   FUNNEL CLOUD                  
##  [37] FUNNEL CLOUD.                  FUNNEL CLOUD/HAIL             
##  [39] FUNNEL CLOUDS                  FUNNELS                       
##  [41] gradient wind                  Gradient wind                 
##  [43] GRADIENT WIND                  GRADIENT WINDS                
##  [45] GUSTNADO                       GUSTNADO AND                  
##  [47] GUSTY LAKE WIND                GUSTY THUNDERSTORM WIND       
##  [49] GUSTY THUNDERSTORM WINDS       Gusty Wind                    
##  [51] GUSTY WIND                     GUSTY WIND/HAIL               
##  [53] GUSTY WIND/HVY RAIN            Gusty wind/rain               
##  [55] Gusty winds                    Gusty Winds                   
##  [57] GUSTY WINDS                    HAIL                          
##  [59] HAIL 0.75                      HAIL 0.88                     
##  [61] HAIL 075                       HAIL 088                      
##  [63] HAIL 1.00                      HAIL 1.75                     
##  [65] HAIL 1.75)                     HAIL 100                      
##  [67] HAIL 125                       HAIL 150                      
##  [69] HAIL 175                       HAIL 200                      
##  [71] HAIL 225                       HAIL 275                      
##  [73] HAIL 450                       HAIL 75                       
##  [75] HAIL 80                        HAIL 88                       
##  [77] HAIL ALOFT                     HAIL DAMAGE                   
##  [79] HAIL FLOODING                  HAIL STORM                    
##  [81] Hail(0.75)                     HAIL/ICY ROADS                
##  [83] HAIL/WIND                      HAIL/WINDS                    
##  [85] HAILSTORM                      HAILSTORMS                    
##  [87] Heavy Rain and Wind            HEAVY RAIN/LIGHTNING          
##  [89] HEAVY RAIN/WIND                HEAVY RAIN; URBAN FLOOD WINDS;
##  [91] HEAVY SNOW AND HIGH WINDS      HEAVY SNOW AND STRONG WINDS   
##  [93] HEAVY SNOW/HIGH WIND           HEAVY SNOW/HIGH WINDS         
##  [95] HEAVY SNOW/HIGH WINDS & FLOOD  HEAVY SNOW/HIGH WINDS/FREEZING
##  [97] HEAVY SNOW/WIND                Heavy surf and wind           
##  [99] HIGH  WINDS                    High Wind                     
## [101] HIGH WIND                      HIGH WIND (G40)               
## [103] HIGH WIND 48                   HIGH WIND 63                  
## [105] HIGH WIND 70                   HIGH WIND AND HEAVY SNOW      
## [107] HIGH WIND AND HIGH TIDES       HIGH WIND AND SEAS            
## [109] HIGH WIND DAMAGE               HIGH WIND/ BLIZZARD           
## [111] HIGH WIND/BLIZZARD             HIGH WIND/BLIZZARD/FREEZING RA
## [113] HIGH WIND/HEAVY SNOW           HIGH WIND/LOW WIND CHILL      
## [115] HIGH WIND/SEAS                 HIGH WIND/WIND CHILL          
## [117] HIGH WIND/WIND CHILL/BLIZZARD  HIGH WINDS                    
## [119] HIGH WINDS 55                  HIGH WINDS 57                 
## [121] HIGH WINDS 58                  HIGH WINDS 63                 
## [123] HIGH WINDS 66                  HIGH WINDS 67                 
## [125] HIGH WINDS 73                  HIGH WINDS 76                 
## [127] HIGH WINDS 80                  HIGH WINDS 82                 
## [129] HIGH WINDS AND WIND CHILL      HIGH WINDS DUST STORM         
## [131] HIGH WINDS HEAVY RAINS         HIGH WINDS/                   
## [133] HIGH WINDS/COASTAL FLOOD       HIGH WINDS/COLD               
## [135] HIGH WINDS/FLOODING            HIGH WINDS/HEAVY RAIN         
## [137] HIGH WINDS/SNOW                HURRICANE OPAL/HIGH WINDS     
## [139] ICE/STRONG WINDS               LATE SEASON HAIL              
## [141] LIGHTING                       LIGHTNING                     
## [143] LIGHTNING  WAUSEON             LIGHTNING AND HEAVY RAIN      
## [145] LIGHTNING AND THUNDERSTORM WIN LIGHTNING AND WINDS           
## [147] LIGHTNING DAMAGE               LIGHTNING FIRE                
## [149] LIGHTNING INJURY               LIGHTNING THUNDERSTORM WINDS  
## [151] LIGHTNING THUNDERSTORM WINDSS  LIGHTNING.                    
## [153] LIGHTNING/HEAVY RAIN           LIGNTNING                     
## [155] LOW WIND CHILL                 MARINE HAIL                   
## [157] MARINE HIGH WIND               MARINE STRONG WIND            
## [159] MARINE THUNDERSTORM WIND       MARINE TSTM WIND              
## [161] MICROBURST WINDS               NON-SEVERE WIND DAMAGE        
## [163] NON-TSTM WIND                  NON SEVERE HAIL               
## [165] NON TSTM WIND                  RAIN AND WIND                 
## [167] RAIN/WIND                      RECORD COLD AND HIGH WIND     
## [169] SEVERE THUNDERSTORM            SEVERE THUNDERSTORM WINDS     
## [171] SEVERE THUNDERSTORMS           small hail                    
## [173] Small Hail                     SMALL HAIL                    
## [175] SNOW- HIGH WIND- WIND CHILL    SNOW AND WIND                 
## [177] SNOW/HIGH WINDS                STORM FORCE WINDS             
## [179] Strong Wind                    STRONG WIND                   
## [181] STRONG WIND GUST               Strong winds                  
## [183] Strong Winds                   STRONG WINDS                  
## [185] THUDERSTORM WINDS              THUNDEERSTORM WINDS           
## [187] THUNDERESTORM WINDS            THUNDERSTORM                  
## [189] THUNDERSTORM  WINDS            THUNDERSTORM DAMAGE           
## [191] THUNDERSTORM DAMAGE TO         THUNDERSTORM HAIL             
## [193] THUNDERSTORM W INDS            Thunderstorm Wind             
## [195] THUNDERSTORM WIND              THUNDERSTORM WIND (G40)       
## [197] THUNDERSTORM WIND 50           THUNDERSTORM WIND 52          
## [199] THUNDERSTORM WIND 56           THUNDERSTORM WIND 59          
## [201] THUNDERSTORM WIND 59 MPH       THUNDERSTORM WIND 59 MPH.     
## [203] THUNDERSTORM WIND 60 MPH       THUNDERSTORM WIND 65 MPH      
## [205] THUNDERSTORM WIND 65MPH        THUNDERSTORM WIND 69          
## [207] THUNDERSTORM WIND 98 MPH       THUNDERSTORM WIND G50         
## [209] THUNDERSTORM WIND G51          THUNDERSTORM WIND G52         
## [211] THUNDERSTORM WIND G55          THUNDERSTORM WIND G60         
## [213] THUNDERSTORM WIND G61          THUNDERSTORM WIND TREES       
## [215] THUNDERSTORM WIND.             THUNDERSTORM WIND/ TREE       
## [217] THUNDERSTORM WIND/ TREES       THUNDERSTORM WIND/AWNING      
## [219] THUNDERSTORM WIND/HAIL         THUNDERSTORM WIND/LIGHTNING   
## [221] THUNDERSTORM WINDS             THUNDERSTORM WINDS      LE CEN
## [223] THUNDERSTORM WINDS 13          THUNDERSTORM WINDS 2          
## [225] THUNDERSTORM WINDS 50          THUNDERSTORM WINDS 52         
## [227] THUNDERSTORM WINDS 53          THUNDERSTORM WINDS 60         
## [229] THUNDERSTORM WINDS 61          THUNDERSTORM WINDS 62         
## [231] THUNDERSTORM WINDS 63 MPH      THUNDERSTORM WINDS AND        
## [233] THUNDERSTORM WINDS FUNNEL CLOU THUNDERSTORM WINDS G          
## [235] THUNDERSTORM WINDS G60         THUNDERSTORM WINDS HAIL       
## [237] THUNDERSTORM WINDS HEAVY RAIN  THUNDERSTORM WINDS LIGHTNING  
## [239] THUNDERSTORM WINDS SMALL STREA THUNDERSTORM WINDS URBAN FLOOD
## [241] THUNDERSTORM WINDS.            THUNDERSTORM WINDS/ FLOOD     
## [243] THUNDERSTORM WINDS/ HAIL       THUNDERSTORM WINDS/FLASH FLOOD
## [245] THUNDERSTORM WINDS/FLOODING    THUNDERSTORM WINDS/FUNNEL CLOU
## [247] THUNDERSTORM WINDS/HAIL        THUNDERSTORM WINDS/HEAVY RAIN 
## [249] THUNDERSTORM WINDS53           THUNDERSTORM WINDSHAIL        
## [251] THUNDERSTORM WINDSS            THUNDERSTORM WINS             
## [253] THUNDERSTORMS                  THUNDERSTORMS WIND            
## [255] THUNDERSTORMS WINDS            THUNDERSTORMW                 
## [257] THUNDERSTORMW 50               THUNDERSTORMW WINDS           
## [259] THUNDERSTORMWINDS              THUNDERSTROM WIND             
## [261] THUNDERSTROM WINDS             THUNDERTORM WINDS             
## [263] THUNDERTSORM WIND              THUNDESTORM WINDS             
## [265] THUNERSTORM WINDS              TORNADO                       
## [267] TORNADO DEBRIS                 TORNADO F0                    
## [269] TORNADO F1                     TORNADO F2                    
## [271] TORNADO F3                     TORNADO/WATERSPOUT            
## [273] TORNADOES                      TORNADOES, TSTM WIND, HAIL    
## [275] TORNADOS                       TORNDAO                       
## [277] TSTM                           TSTM HEAVY RAIN               
## [279] Tstm Wind                      TSTM WIND                     
## [281] TSTM WIND  (G45)               TSTM WIND (41)                
## [283] TSTM WIND (G35)                TSTM WIND (G40)               
## [285] TSTM WIND (G45)                TSTM WIND 40                  
## [287] TSTM WIND 45                   TSTM WIND 50                  
## [289] TSTM WIND 51                   TSTM WIND 52                  
## [291] TSTM WIND 55                   TSTM WIND 65)                 
## [293] TSTM WIND AND LIGHTNING        TSTM WIND DAMAGE              
## [295] TSTM WIND G45                  TSTM WIND G58                 
## [297] TSTM WIND/HAIL                 TSTM WINDS                    
## [299] TSTM WND                       TSTMW                         
## [301] TUNDERSTORM WIND               WAKE LOW WIND                 
## [303] WALL CLOUD/FUNNEL CLOUD        WATERSPOUT-TORNADO            
## [305] WATERSPOUT FUNNEL CLOUD        WATERSPOUT TORNADO            
## [307] WATERSPOUT/ TORNADO            WATERSPOUT/TORNADO            
## [309] Whirlwind                      WHIRLWIND                     
## [311] Wind                           WIND                          
## [313] WIND ADVISORY                  WIND AND WAVE                 
## [315] WIND CHILL                     WIND CHILL/HIGH WIND          
## [317] Wind Damage                    WIND DAMAGE                   
## [319] WIND GUSTS                     WIND STORM                    
## [321] WIND/HAIL                      WINDS                         
## [323] WINTER STORM HIGH WINDS        WINTER STORM/HIGH WIND        
## [325] WINTER STORM/HIGH WINDS        WND                           
## 985 Levels:    HIGH SURF ADVISORY  COASTAL FLOOD ... WND
regex <- "COLD|HEAT"
Storm <- Storm[, eventExtremeTemp := indicator(regex)]
##  [1] Cold                         COLD                        
##  [3] COLD AIR FUNNEL              COLD AIR FUNNELS            
##  [5] COLD AIR TORNADO             Cold and Frost              
##  [7] COLD AND FROST               COLD AND SNOW               
##  [9] COLD AND WET CONDITIONS      Cold Temperature            
## [11] COLD TEMPERATURES            COLD WAVE                   
## [13] COLD WEATHER                 COLD WIND CHILL TEMPERATURES
## [15] COLD/WIND CHILL              COLD/WINDS                  
## [17] DROUGHT/EXCESSIVE HEAT       Excessive Cold              
## [19] EXCESSIVE HEAT               EXCESSIVE HEAT/DROUGHT      
## [21] Extended Cold                Extreme Cold                
## [23] EXTREME COLD                 EXTREME COLD/WIND CHILL     
## [25] EXTREME HEAT                 EXTREME/RECORD COLD         
## [27] FOG AND COLD TEMPERATURES    HEAT                        
## [29] HEAT DROUGHT                 Heat Wave                   
## [31] HEAT WAVE                    HEAT WAVE DROUGHT           
## [33] HEAT WAVES                   HEAT/DROUGHT                
## [35] Heatburst                    HIGH WINDS/COLD             
## [37] Prolong Cold                 PROLONG COLD                
## [39] PROLONG COLD/SNOW            RECORD  COLD                
## [41] Record Cold                  RECORD COLD                 
## [43] RECORD COLD AND HIGH WIND    RECORD COLD/FROST           
## [45] Record Heat                  RECORD HEAT                 
## [47] RECORD HEAT WAVE             RECORD SNOW/COLD            
## [49] RECORD/EXCESSIVE HEAT        SEVERE COLD                 
## [51] SNOW AND COLD                SNOW/ BITTER COLD           
## [53] SNOW/COLD                    SNOW\\COLD                  
## [55] Unseasonable Cold            UNSEASONABLY COLD           
## [57] UNUSUALLY COLD              
## 985 Levels:    HIGH SURF ADVISORY  COASTAL FLOOD ... WND
regexFlood <- "(\\bFL\\S+?Storm)"
regexRain <- "RAIN|PRECIP|SHOWER"
regex <- paste(regexFlood, regexRain, sep="|")
Storm <- Storm[, eventFlood := indicator(regex)]
##  [1] BELOW NORMAL PRECIPITATION     BLIZZARD/FREEZING RAIN        
##  [3] EARLY RAIN                     EXCESSIVE PRECIPITATION       
##  [5] EXCESSIVE RAIN                 EXCESSIVE RAINFALL            
##  [7] FLASH FLOOD - HEAVY RAIN       FLASH FLOOD/HEAVY RAIN        
##  [9] FLASH FLOODING/THUNDERSTORM WI FLOOD & HEAVY RAIN            
## [11] FLOOD/RAIN/WIND                FLOOD/RAIN/WINDS              
## [13] FLOODING/HEAVY RAIN            Freezing rain                 
## [15] Freezing Rain                  FREEZING RAIN                 
## [17] FREEZING RAIN AND SLEET        FREEZING RAIN AND SNOW        
## [19] FREEZING RAIN SLEET AND        FREEZING RAIN SLEET AND LIGHT 
## [21] FREEZING RAIN/SLEET            FREEZING RAIN/SNOW            
## [23] GUSTY WIND/HVY RAIN            Gusty wind/rain               
## [25] HEAVY PRECIPATATION            Heavy Precipitation           
## [27] HEAVY PRECIPITATION            Heavy rain                    
## [29] Heavy Rain                     HEAVY RAIN                    
## [31] HEAVY RAIN AND FLOOD           Heavy Rain and Wind           
## [33] HEAVY RAIN EFFECTS             HEAVY RAIN/FLOODING           
## [35] Heavy Rain/High Surf           HEAVY RAIN/LIGHTNING          
## [37] HEAVY RAIN/MUDSLIDES/FLOOD     HEAVY RAIN/SEVERE WEATHER     
## [39] HEAVY RAIN/SMALL STREAM URBAN  HEAVY RAIN/SNOW               
## [41] HEAVY RAIN/URBAN FLOOD         HEAVY RAIN/WIND               
## [43] HEAVY RAIN; URBAN FLOOD WINDS; HEAVY RAINFALL                
## [45] HEAVY RAINS                    HEAVY RAINS/FLOODING          
## [47] HEAVY SHOWER                   HEAVY SHOWERS                 
## [49] HEAVY SNOW   FREEZING RAIN     Heavy snow shower             
## [51] HEAVY SNOW/FREEZING RAIN       HIGH WINDS HEAVY RAINS        
## [53] HIGH WINDS/HEAVY RAIN          HVY RAIN                      
## [55] LIGHT FREEZING RAIN            LIGHT SNOW/FREEZING PRECIP    
## [57] LIGHTNING AND HEAVY RAIN       LIGHTNING/HEAVY RAIN          
## [59] LOCALLY HEAVY RAIN             MIXED PRECIP                  
## [61] Mixed Precipitation            MIXED PRECIPITATION           
## [63] MONTHLY PRECIPITATION          Monthly Rainfall              
## [65] MONTHLY RAINFALL               NORMAL PRECIPITATION          
## [67] PROLONGED RAIN                 RAIN                          
## [69] RAIN (HEAVY)                   RAIN AND WIND                 
## [71] Rain Damage                    RAIN/SNOW                     
## [73] RAIN/WIND                      RAINSTORM                     
## [75] RECORD LOW RAINFALL            RECORD PRECIPITATION          
## [77] RECORD RAINFALL                RECORD/EXCESSIVE RAINFALL     
## [79] SLEET & FREEZING RAIN          SLEET/FREEZING RAIN           
## [81] SLEET/RAIN/SNOW                SNOW FREEZING RAIN            
## [83] SNOW SHOWERS                   SNOW/FREEZING RAIN            
## [85] SNOW/RAIN                      SNOW/RAIN/SLEET               
## [87] SNOW/SLEET/FREEZING RAIN       SNOW/SLEET/RAIN               
## [89] Thundersnow shower             THUNDERSTORM WINDS HEAVY RAIN 
## [91] THUNDERSTORM WINDS/HEAVY RAIN  TORRENTIAL RAIN               
## [93] Torrential Rainfall            TSTM HEAVY RAIN               
## [95] UNSEASONAL RAIN               
## 985 Levels:    HIGH SURF ADVISORY  COASTAL FLOOD ... WND
regex <- "(SNOW)|(ICE)|(ICY)|(FREEZ)|(WINT)"
Storm <- Storm[, eventWinter := indicator(regex)]
##   [1] ACCUMULATED SNOWFALL           AGRICULTURAL FREEZE           
##   [3] Black Ice                      BLACK ICE                     
##   [5] BLIZZARD AND HEAVY SNOW        BLIZZARD/FREEZING RAIN        
##   [7] BLIZZARD/HEAVY SNOW            BLIZZARD/WINTER STORM         
##   [9] blowing snow                   Blowing Snow                  
##  [11] BLOWING SNOW                   BLOWING SNOW- EXTREME WIND CHI
##  [13] BLOWING SNOW & EXTREME WIND CH BLOWING SNOW/EXTREME WIND CHIL
##  [15] COLD AND SNOW                  Damaging Freeze               
##  [17] DAMAGING FREEZE                Drifting Snow                 
##  [19] EARLY FREEZE                   EARLY SNOW                    
##  [21] Early snowfall                 EARLY SNOWFALL                
##  [23] EXCESSIVE SNOW                 FALLING SNOW/ICE              
##  [25] FIRST SNOW                     FLASH FLOOD FROM ICE JAMS     
##  [27] Freeze                         FREEZE                        
##  [29] Freezing drizzle               Freezing Drizzle              
##  [31] FREEZING DRIZZLE               FREEZING DRIZZLE AND FREEZING 
##  [33] Freezing Fog                   FREEZING FOG                  
##  [35] Freezing rain                  Freezing Rain                 
##  [37] FREEZING RAIN                  FREEZING RAIN AND SLEET       
##  [39] FREEZING RAIN AND SNOW         FREEZING RAIN SLEET AND       
##  [41] FREEZING RAIN SLEET AND LIGHT  FREEZING RAIN/SLEET           
##  [43] FREEZING RAIN/SNOW             Freezing Spray                
##  [45] Frost/Freeze                   FROST/FREEZE                  
##  [47] FROST\\FREEZE                  GLAZE ICE                     
##  [49] GLAZE/ICE STORM                HAIL/ICY ROADS                
##  [51] HARD FREEZE                    HEAVY LAKE SNOW               
##  [53] HEAVY RAIN/SNOW                HEAVY SNOW                    
##  [55] HEAVY SNOW-SQUALLS             HEAVY SNOW   FREEZING RAIN    
##  [57] HEAVY SNOW & ICE               HEAVY SNOW AND                
##  [59] HEAVY SNOW AND HIGH WINDS      HEAVY SNOW AND ICE            
##  [61] HEAVY SNOW AND ICE STORM       HEAVY SNOW AND STRONG WINDS   
##  [63] HEAVY SNOW ANDBLOWING SNOW     Heavy snow shower             
##  [65] HEAVY SNOW SQUALLS             HEAVY SNOW/BLIZZARD           
##  [67] HEAVY SNOW/BLIZZARD/AVALANCHE  HEAVY SNOW/BLOWING SNOW       
##  [69] HEAVY SNOW/FREEZING RAIN       HEAVY SNOW/HIGH               
##  [71] HEAVY SNOW/HIGH WIND           HEAVY SNOW/HIGH WINDS         
##  [73] HEAVY SNOW/HIGH WINDS & FLOOD  HEAVY SNOW/HIGH WINDS/FREEZING
##  [75] HEAVY SNOW/ICE                 HEAVY SNOW/ICE STORM          
##  [77] HEAVY SNOW/SLEET               HEAVY SNOW/SQUALLS            
##  [79] HEAVY SNOW/WIND                HEAVY SNOW/WINTER STORM       
##  [81] HEAVY SNOWPACK                 HEAVY WET SNOW                
##  [83] HIGH WIND AND HEAVY SNOW       HIGH WIND/BLIZZARD/FREEZING RA
##  [85] HIGH WIND/HEAVY SNOW           HIGH WINDS/SNOW               
##  [87] ICE                            ICE AND SNOW                  
##  [89] ICE FLOES                      Ice Fog                       
##  [91] ICE JAM                        Ice jam flood (minor          
##  [93] ICE JAM FLOODING               ICE ON ROAD                   
##  [95] ICE PELLETS                    ICE ROADS                     
##  [97] ICE STORM                      ICE STORM AND SNOW            
##  [99] ICE STORM/FLASH FLOOD          Ice/Snow                      
## [101] ICE/SNOW                       ICE/STRONG WINDS              
## [103] Icestorm/Blizzard              Icy Roads                     
## [105] ICY ROADS                      LACK OF SNOW                  
## [107] LAKE-EFFECT SNOW               Lake Effect Snow              
## [109] LAKE EFFECT SNOW               Late-season Snowfall          
## [111] LATE FREEZE                    LATE SEASON SNOW              
## [113] Late Season Snowfall           LATE SNOW                     
## [115] LIGHT FREEZING RAIN            Light snow                    
## [117] Light Snow                     LIGHT SNOW                    
## [119] LIGHT SNOW AND SLEET           Light Snow/Flurries           
## [121] LIGHT SNOW/FREEZING PRECIP     Light Snowfall                
## [123] MODERATE SNOW                  MODERATE SNOWFALL             
## [125] Monthly Snowfall               MONTHLY SNOWFALL              
## [127] Mountain Snows                 NEAR RECORD SNOW              
## [129] PATCHY ICE                     PROLONG COLD/SNOW             
## [131] RAIN/SNOW                      Record May Snow               
## [133] RECORD SNOW                    RECORD SNOW/COLD              
## [135] RECORD SNOWFALL                Record Winter Snow            
## [137] Seasonal Snowfall              SLEET & FREEZING RAIN         
## [139] SLEET/FREEZING RAIN            SLEET/ICE STORM               
## [141] SLEET/RAIN/SNOW                SLEET/SNOW                    
## [143] Snow                           SNOW                          
## [145] SNOW- HIGH WIND- WIND CHILL    Snow Accumulation             
## [147] SNOW ACCUMULATION              SNOW ADVISORY                 
## [149] SNOW AND COLD                  SNOW AND HEAVY SNOW           
## [151] Snow and Ice                   SNOW AND ICE                  
## [153] SNOW AND ICE STORM             Snow and sleet                
## [155] SNOW AND SLEET                 SNOW AND WIND                 
## [157] SNOW DROUGHT                   SNOW FREEZING RAIN            
## [159] SNOW SHOWERS                   SNOW SLEET                    
## [161] SNOW SQUALL                    Snow squalls                  
## [163] Snow Squalls                   SNOW SQUALLS                  
## [165] SNOW/ BITTER COLD              SNOW/ ICE                     
## [167] SNOW/BLOWING SNOW              SNOW/COLD                     
## [169] SNOW/FREEZING RAIN             SNOW/HEAVY SNOW               
## [171] SNOW/HIGH WINDS                SNOW/ICE                      
## [173] SNOW/ICE STORM                 SNOW/RAIN                     
## [175] SNOW/RAIN/SLEET                SNOW/SLEET                    
## [177] SNOW/SLEET/FREEZING RAIN       SNOW/SLEET/RAIN               
## [179] SNOW\\COLD                     SNOWFALL RECORD               
## [181] SNOWMELT FLOODING              SNOWSTORM                     
## [183] THUNDERSNOW                    Thundersnow shower            
## [185] UNUSUALLY LATE SNOW            WET SNOW                      
## [187] WINTER MIX                     WINTER STORM                  
## [189] WINTER STORM HIGH WINDS        WINTER STORM/HIGH WIND        
## [191] WINTER STORM/HIGH WINDS        WINTER STORMS                 
## [193] Winter Weather                 WINTER WEATHER                
## [195] WINTER WEATHER MIX             WINTER WEATHER/MIX            
## [197] WINTERY MIX                    Wintry mix                    
## [199] Wintry Mix                     WINTRY MIX                    
## 985 Levels:    HIGH SURF ADVISORY  COASTAL FLOOD ... WND

Calculate the proportion of records that don’t satisfy any one of the defined indicators. Calculate the number of unique event types among these records. List the ungrouped unique event types.

where <- expression(eventConvection == FALSE & eventExtremeTemp == FALSE & eventFlood == FALSE & eventWinter == FALSE)
ungrouped <- Storm[eval(where), list(n = .N, prop = .N / nrow(Storm))]
prop <- Storm[eval(where), .N / nrow(Storm)]
message(sprintf("Number of records that does not satisfy any single indicator: %.0d (%.2f%%)", ungrouped$n, ungrouped$prop * 100))
## Number of records that does not satisfy any single indicator: 107716 (11.94%)
uniqueEvtype <- unique(Storm[eval(where), evtype])
message(sprintf("Number of unique event types: %.0d", length(uniqueEvtype)))
## Number of unique event types: 391
uniqueEvtype[order(uniqueEvtype)]
##   [1]    HIGH SURF ADVISORY           COASTAL FLOOD                
##   [3]  FLASH FLOOD                    WATERSPOUT                   
##   [5] ?                              ABNORMAL WARMTH               
##   [7] ABNORMALLY DRY                 ABNORMALLY WET                
##   [9] APACHE COUNTY                  ASTRONOMICAL HIGH TIDE        
##  [11] ASTRONOMICAL LOW TIDE          AVALANCE                      
##  [13] AVALANCHE                      BEACH EROSIN                  
##  [15] Beach Erosion                  BEACH EROSION                 
##  [17] BEACH EROSION/COASTAL FLOOD    BEACH FLOOD                   
##  [19] BLIZZARD                       Blizzard Summary              
##  [21] BLIZZARD WEATHER               BLOW-OUT TIDE                 
##  [23] BLOW-OUT TIDES                 BLOWING DUST                  
##  [25] BREAKUP FLOODING               BRUSH FIRE                    
##  [27] BRUSH FIRES                    COASTAL  FLOODING/EROSION     
##  [29] COASTAL EROSION                Coastal Flood                 
##  [31] COASTAL FLOOD                  coastal flooding              
##  [33] Coastal Flooding               COASTAL FLOODING              
##  [35] COASTAL FLOODING/EROSION       Coastal Storm                 
##  [37] COASTAL STORM                  COASTAL SURGE                 
##  [39] COASTAL/TIDAL FLOOD            COASTALFLOOD                  
##  [41] COASTALSTORM                   COOL AND WET                  
##  [43] COOL SPELL                     CSTL FLOODING/EROSION         
##  [45] DAM BREAK                      DAM FAILURE                   
##  [47] DENSE FOG                      DENSE SMOKE                   
##  [49] DOWNBURST                      DRIEST MONTH                  
##  [51] DROUGHT                        DROWNING                      
##  [53] DRY                            DRY CONDITIONS                
##  [55] DRY HOT WEATHER                DRY MICROBURST                
##  [57] DRY MICROBURST 50              DRY MICROBURST 53             
##  [59] DRY MICROBURST 58              DRY MICROBURST 61             
##  [61] DRY MICROBURST 84              DRY PATTERN                   
##  [63] DRY SPELL                      DRY WEATHER                   
##  [65] DRYNESS                        DUST DEVEL                    
##  [67] Dust Devil                     DUST DEVIL                    
##  [69] DUST DEVIL WATERSPOUT          DUST STORM                    
##  [71] DUSTSTORM                      Early Frost                   
##  [73] EARLY FROST                    Erosion/Cstl Flood            
##  [75] EXCESSIVE                      EXCESSIVE WETNESS             
##  [77] EXCESSIVELY DRY                EXTREMELY WET                 
##  [79] FIRST FROST                    FLASH FLOOD                   
##  [81] FLASH FLOOD LANDSLIDES         FLASH FLOOD/                  
##  [83] FLASH FLOOD/ FLOOD             FLASH FLOOD/ STREET           
##  [85] FLASH FLOOD/FLOOD              FLASH FLOOD/LANDSLIDE         
##  [87] FLASH FLOODING                 FLASH FLOODING/FLOOD          
##  [89] FLASH FLOODS                   FLASH FLOOODING               
##  [91] Flood                          FLOOD                         
##  [93] FLOOD FLASH                    FLOOD FLOOD/FLASH             
##  [95] FLOOD WATCH/                   FLOOD/FLASH                   
##  [97] Flood/Flash Flood              FLOOD/FLASH FLOOD             
##  [99] FLOOD/FLASH FLOODING           FLOOD/FLASH/FLOOD             
## [101] FLOOD/FLASHFLOOD               FLOOD/RIVER FLOOD             
## [103] FLOODING                       FLOODS                        
## [105] FOG                            FOREST FIRES                  
## [107] Frost                          FROST                         
## [109] Glaze                          GLAZE                         
## [111] GRASS FIRES                    GROUND BLIZZARD               
## [113] HAZARDOUS SURF                 HEAVY MIX                     
## [115] HEAVY SEAS                     Heavy Surf                    
## [117] HEAVY SURF                     HEAVY SURF COASTAL FLOODING   
## [119] HEAVY SURF/HIGH SURF           HEAVY SWELLS                  
## [121] HIGH                           HIGH  SWELLS                  
## [123] HIGH SEAS                      High Surf                     
## [125] HIGH SURF                      HIGH SURF ADVISORIES          
## [127] HIGH SURF ADVISORY             HIGH SWELLS                   
## [129] HIGH TEMPERATURE RECORD        HIGH TIDES                    
## [131] HIGH WATER                     HIGH WAVES                    
## [133] HIGHWAY FLOODING               Hot and Dry                   
## [135] HOT PATTERN                    HOT SPELL                     
## [137] HOT WEATHER                    HOT/DRY PATTERN               
## [139] HURRICANE                      HURRICANE-GENERATED SWELLS    
## [141] Hurricane Edouard              HURRICANE EMILY               
## [143] HURRICANE ERIN                 HURRICANE FELIX               
## [145] HURRICANE GORDON               HURRICANE OPAL                
## [147] HURRICANE/TYPHOON              HYPERTHERMIA/EXPOSURE         
## [149] HYPOTHERMIA                    Hypothermia/Exposure          
## [151] HYPOTHERMIA/EXPOSURE           LAKE FLOOD                    
## [153] LAKESHORE FLOOD                LANDSLIDE                     
## [155] LANDSLIDE/URBAN FLOOD          LANDSLIDES                    
## [157] Landslump                      LANDSLUMP                     
## [159] LANDSPOUT                      LARGE WALL CLOUD              
## [161] LOCAL FLASH FLOOD              LOCAL FLOOD                   
## [163] LOW TEMPERATURE                LOW TEMPERATURE RECORD        
## [165] MAJOR FLOOD                    Marine Accident               
## [167] MARINE MISHAP                  Metro Storm, May 26           
## [169] Microburst                     MICROBURST                    
## [171] Mild and Dry Pattern           MILD PATTERN                  
## [173] MILD/DRY PATTERN               MINOR FLOOD                   
## [175] Minor Flooding                 MINOR FLOODING                
## [177] MONTHLY TEMPERATURE            MUD SLIDE                     
## [179] MUD SLIDES                     MUD SLIDES URBAN FLOODING     
## [181] MUD/ROCK SLIDE                 Mudslide                      
## [183] MUDSLIDE                       MUDSLIDE/LANDSLIDE            
## [185] Mudslides                      MUDSLIDES                     
## [187] No Severe Weather              NONE                          
## [189] NORTHERN LIGHTS                Other                         
## [191] OTHER                          PATCHY DENSE FOG              
## [193] PROLONG WARMTH                 RAPIDLY RISING WATER          
## [195] RECORD COOL                    Record dry month              
## [197] RECORD DRYNESS                 Record High                   
## [199] RECORD HIGH                    RECORD HIGH TEMPERATURE       
## [201] RECORD HIGH TEMPERATURES       RECORD LOW                    
## [203] Record temperature             RECORD TEMPERATURE            
## [205] Record Temperatures            RECORD TEMPERATURES           
## [207] RECORD WARM                    RECORD WARM TEMPS.            
## [209] Record Warmth                  RECORD WARMTH                 
## [211] RED FLAG CRITERIA              RED FLAG FIRE WX              
## [213] REMNANTS OF FLOYD              RIP CURRENT                   
## [215] RIP CURRENTS                   RIP CURRENTS HEAVY SURF       
## [217] RIP CURRENTS/HEAVY SURF        RIVER AND STREAM FLOOD        
## [219] RIVER FLOOD                    River Flooding                
## [221] RIVER FLOODING                 ROCK SLIDE                    
## [223] ROGUE WAVE                     ROTATING WALL CLOUD           
## [225] ROUGH SEAS                     ROUGH SURF                    
## [227] RURAL FLOOD                    Saharan Dust                  
## [229] SAHARAN DUST                   SEICHE                        
## [231] SEVERE TURBULENCE              SLEET                         
## [233] SLEET STORM                    SMALL STREAM                  
## [235] SMALL STREAM AND               SMALL STREAM AND URBAN FLOOD  
## [237] SMALL STREAM AND URBAN FLOODIN SMALL STREAM FLOOD            
## [239] SMALL STREAM FLOODING          SMALL STREAM URBAN FLOOD      
## [241] SMALL STREAM/URBAN FLOOD       Sml Stream Fld                
## [243] SMOKE                          SOUTHEAST                     
## [245] STORM SURGE                    STORM SURGE/TIDE              
## [247] STREAM FLOODING                STREET FLOOD                  
## [249] STREET FLOODING                Summary August 10             
## [251] Summary August 11              Summary August 17             
## [253] Summary August 2-3             Summary August 21             
## [255] Summary August 28              Summary August 4              
## [257] Summary August 7               Summary August 9              
## [259] Summary Jan 17                 Summary July 23-24            
## [261] Summary June 18-19             Summary June 5-6              
## [263] Summary June 6                 Summary of April 12           
## [265] Summary of April 13            Summary of April 21           
## [267] Summary of April 27            Summary of April 3rd          
## [269] Summary of August 1            Summary of July 11            
## [271] Summary of July 2              Summary of July 22            
## [273] Summary of July 26             Summary of July 29            
## [275] Summary of July 3              Summary of June 10            
## [277] Summary of June 11             Summary of June 12            
## [279] Summary of June 13             Summary of June 15            
## [281] Summary of June 16             Summary of June 18            
## [283] Summary of June 23             Summary of June 24            
## [285] Summary of June 3              Summary of June 30            
## [287] Summary of June 4              Summary of June 6             
## [289] Summary of March 14            Summary of March 23           
## [291] Summary of March 24            SUMMARY OF MARCH 24-25        
## [293] SUMMARY OF MARCH 27            SUMMARY OF MARCH 29           
## [295] Summary of May 10              Summary of May 13             
## [297] Summary of May 14              Summary of May 22             
## [299] Summary of May 22 am           Summary of May 22 pm          
## [301] Summary of May 26 am           Summary of May 26 pm          
## [303] Summary of May 31 am           Summary of May 31 pm          
## [305] Summary of May 9-10            Summary Sept. 25-26           
## [307] Summary September 20           Summary September 23          
## [309] Summary September 3            Summary September 4           
## [311] Summary: Nov. 16               Summary: Nov. 6-7             
## [313] Summary: Oct. 20-21            Summary: October 31           
## [315] Summary: Sept. 18              Temperature record            
## [317] TIDAL FLOOD                    Tidal Flooding                
## [319] TIDAL FLOODING                 TROPICAL DEPRESSION           
## [321] TROPICAL STORM                 TROPICAL STORM ALBERTO        
## [323] TROPICAL STORM DEAN            TROPICAL STORM GORDON         
## [325] TROPICAL STORM JERRY           TSUNAMI                       
## [327] TYPHOON                        UNSEASONABLY COOL             
## [329] UNSEASONABLY COOL & WET        UNSEASONABLY DRY              
## [331] UNSEASONABLY HOT               UNSEASONABLY WARM             
## [333] UNSEASONABLY WARM & WET        UNSEASONABLY WARM AND DRY     
## [335] UNSEASONABLY WARM YEAR         UNSEASONABLY WARM/WET         
## [337] UNSEASONABLY WET               UNSEASONAL LOW TEMP           
## [339] UNUSUAL WARMTH                 UNUSUAL/RECORD WARMTH         
## [341] UNUSUALLY WARM                 URBAN AND SMALL               
## [343] URBAN AND SMALL STREAM         URBAN AND SMALL STREAM FLOOD  
## [345] URBAN AND SMALL STREAM FLOODIN Urban flood                   
## [347] Urban Flood                    URBAN FLOOD                   
## [349] URBAN FLOOD LANDSLIDE          Urban Flooding                
## [351] URBAN FLOODING                 URBAN FLOODS                  
## [353] URBAN SMALL                    URBAN SMALL STREAM FLOOD      
## [355] URBAN/SMALL                    URBAN/SMALL FLOODING          
## [357] URBAN/SMALL STREAM             URBAN/SMALL STREAM  FLOOD     
## [359] URBAN/SMALL STREAM FLOOD       URBAN/SMALL STREAM FLOODING   
## [361] URBAN/SMALL STRM FLDG          URBAN/SML STREAM FLD          
## [363] URBAN/SML STREAM FLDG          URBAN/STREET FLOODING         
## [365] VERY DRY                       VERY WARM                     
## [367] VOG                            Volcanic Ash                  
## [369] VOLCANIC ASH                   Volcanic Ash Plume            
## [371] VOLCANIC ASHFALL               VOLCANIC ERUPTION             
## [373] WALL CLOUD                     WARM DRY CONDITIONS           
## [375] WARM WEATHER                   WATER SPOUT                   
## [377] WATERSPOUT                     WATERSPOUT-                   
## [379] WATERSPOUT/                    WATERSPOUTS                   
## [381] WAYTERSPOUT                    wet micoburst                 
## [383] WET MICROBURST                 Wet Month                     
## [385] WET WEATHER                    Wet Year                      
## [387] WILD FIRES                     WILD/FOREST FIRE              
## [389] WILD/FOREST FIRES              WILDFIRE                      
## [391] WILDFIRES                     
## 985 Levels:    HIGH SURF ADVISORY  COASTAL FLOOD ... WND

Create an Other variable for ungrouped event types.

Storm <- Storm[, eventOther := eventConvection == FALSE & eventExtremeTemp == FALSE & eventFlood == FALSE & eventWinter == FALSE]

A crosstabulation for the event type categories is below.

groupby <- expression(list(eventConvection, eventExtremeTemp, eventFlood, eventWinter, eventOther))
Storm[, .N, eval(groupby)][order(eventConvection, eventExtremeTemp, eventFlood, eventWinter, eventOther, decreasing=TRUE)]
##     eventConvection eventExtremeTemp eventFlood eventWinter eventOther
##  1:            TRUE             TRUE      FALSE       FALSE      FALSE
##  2:            TRUE            FALSE       TRUE       FALSE      FALSE
##  3:            TRUE            FALSE      FALSE        TRUE      FALSE
##  4:            TRUE            FALSE      FALSE       FALSE      FALSE
##  5:           FALSE             TRUE      FALSE        TRUE      FALSE
##  6:           FALSE             TRUE      FALSE       FALSE      FALSE
##  7:           FALSE            FALSE       TRUE        TRUE      FALSE
##  8:           FALSE            FALSE       TRUE       FALSE      FALSE
##  9:           FALSE            FALSE      FALSE        TRUE      FALSE
## 10:           FALSE            FALSE      FALSE       FALSE       TRUE
##          N
##  1:   1561
##  2:     31
##  3:     29
##  4: 736119
##  5:      9
##  6:   3541
##  7:    354
##  8:  11963
##  9:  40974
## 10: 107716

Create Event Type Categories

Records can have multiple events listed in evtype and will need a categorized heirarchy of event types, The hierarchy is as follows:

  1. Convection (including lightning, tornado, thunderstorm, wind, and hail)
  2. Extreme temperature (including hot and cold)
  3. Flood (including flood, flash flood, rain)
  4. Winter (including snow, ice, freeze, or winter weather)
  5. Other

THUNDERSTORM WINDS/FLASH FLOOD would be assigned to the Convection category.

Storm <- Storm[, eventCategory := ifelse(eventConvection, 1, ifelse(eventExtremeTemp, 2, ifelse(eventFlood, 3, ifelse(eventWinter, 4, ifelse(eventOther, 5, NA)))))]
labels <- c("Convection", "Extreme temperature", "Flood", "Winter", "Other")
Storm <- Storm[, eventCategory := factor(eventCategory, labels=labels)]
Storm[, .N, eventCategory]
##          eventCategory      N
## 1:          Convection 737740
## 2:               Flood  12317
## 3:              Winter  40974
## 4: Extreme temperature   3550
## 5:               Other 107716

Restrict to 50 states

Restrict the data to records from the 50 states. Use R’s built-in state.abb dataset.

Storm <- Storm[state %in% state.abb]

Reshape data

Reshape data table with essential variables for tabulation and plotting.

labels <- c("Convection", "Extreme temperature", "Flood", "Winter", "Other")
D2 <- rbind(Storm[, list(state, eventCategory = factor(eventCategory, labels=labels), outcome = "Fatalities (thousands)", value = fatalities / 1E3)],
            Storm[, list(state, eventCategory = factor(eventCategory, labels=labels), outcome = "Injuries (thousands)", value = injuries / 1E3)],
            Storm[, list(state, eventCategory = factor(eventCategory, labels=labels), outcome = "Property damage ($, billions)", value = propertyDamage / 1E9)])

Tabulate by state and category, and by state. For the state tabulation, rank each state according to outcome.

tabulationStateCategory <- D2[, list(value = sum(value)), list(state, eventCategory, outcome)]
tabulationState <- D2[, list(value = sum(value)), list(state, outcome)]
tabulationState <- tabulationState[, rank := abs(rank(value, ties.method="random") - 51), list(outcome)]

Results

Plot each state as a coxcomb. Each rose shows the magnitude of each outcome Fatalities, Injuries and Property Damage. The color of each bar segment corresponds to event category.

tabulationStateCategory <- tabulationStateCategory[, valueScaled := scale(value, center=FALSE), list(outcome)]
ggplot(tabulationStateCategory, aes(x=outcome, y=valueScaled, fill=eventCategory)) +
  geom_bar(alpha=1, stat="identity") +
  coord_polar(theta="x") +
  scale_fill_brewer(name="Category", palette="Set1") +
  scale_x_discrete(name="", labels=c("F", "I", "P")) +
  scale_y_continuous(name="", labels=NULL) +
  facet_wrap(~ state, nrow=5, ncol=10) +
  labs(title="Comparison of states on outcomes from storms and other severe weather events") +
  theme(legend.position="top") +
  theme(axis.ticks.y=element_blank(),
        panel.grid=element_blank())

Tabulate the highest ranking state for each outcome.

Fatalities

top <- tabulationState[grepl("Fatal", outcome) & rank <= 1, state]
where <- expression(state %in% top & grepl("Fatal", outcome))
select <- expression(list(state, value = format(value * 1E3, big.mark=","), eventCategory))
tabulation <- tabulationStateCategory[eval(where), eval(select)]
tabulation <- tabulation[order(value, decreasing=TRUE)]
print(xtable(tabulation, digits=0), type="html", include.rownames=FALSE)
state value eventCategory
IL 998 Extreme temperature
IL 375 Convection
IL 28 Other
IL 20 Winter
IL 0 Flood

Injuries

top <- tabulationState[grepl("Inj", outcome) & rank <= 1, state]
where <- expression(state %in% top & grepl("Inj", outcome))
select <- expression(list(state, value = format(value * 1E3, big.mark=","), eventCategory))
tabulation <- tabulationStateCategory[eval(where), eval(select)]
tabulation <- tabulation[order(value, decreasing=TRUE)]
print(xtable(tabulation, digits=0), type="html", include.rownames=FALSE)
state value eventCategory
TX 9,532 Convection
TX 7,111 Other
TX 787 Extreme temperature
TX 211 Winter
TX
26 </td> <td> Flood </td> </tr>

Property damage

top <- tabulationState[grepl("Prop", outcome) & rank <= 1, state]
where <- expression(state %in% top & grepl("Prop", outcome))
select <- expression(list(state, value = sprintf("$%s billion", format(round(value, digits=1), big.mark=",")), eventCategory))
tabulation <- tabulationStateCategory[eval(where), eval(select)]
tabulation <- tabulation[order(value, decreasing=TRUE)]
print(xtable(tabulation, digits=0), type="html", include.rownames=FALSE)
state value eventCategory
CA $122.5 billion Other
CA $ 0.7 billion Convection
CA $ 0.3 billion Flood
CA $ 0.1 billion Winter
CA $ 0.0 billion Extreme temperature