Synopsis

The following project is based on the NOAA public data. On it, we are going to analyze the most harmful events related with meteorological events. The data supplied is registered from 1950 until 2011. First, we made a pre-processing and loading of the data. Then, we group some results and present it in a suitable mode.

Basically, we present the most harmful events based on two different effects: the personal damage caused and the economic repercussion.

Data processing

Reading the data

First we extract the data from the NOAA

if(!file.exists("./storm_data.csv")){
    download.file("http://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2","./storm_data.csv",mode="wb")
    
}
  
data <- read.csv("./storm_data.csv",header=TRUE)

Pre-processing the data

Initially, we are formatting the data, converting rows with dates to a proper format. Then, we extract and create a new column with the year of each register

Dates <- as.character(data$BGN_DATE)
Dates_2 <- as.Date(Dates,"%m/%d/%Y")
year <- format(Dates_2,"%Y")
data_bind <- cbind(data,year)
data_bind$year <- as.integer(as.character(data_bind$year))

Simplifying the dataset

As we can see in the code below, the vast majority of the registers are only within the period between years 1996 and 2012, from first quartile to the end. Added to this, we have to consider that years 1994 and 1995 have a lot of bad or incongruent registers, so the idea of left this data out of the scope of the study is reinforced.

summary(data_bind$year)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1950    1995    2002    1999    2007    2011

Next step is creating the new subset only from 1996.

data_post_1995 <- data_bind[data_bind[,38]>1995,] 

As we are only interested in personal damage, now we are groupping and adding the results by event type

fatalities_by_events <- aggregate(data_post_1995$FATALITIES,list(data_post_1995$EVTYPE),sum)
injuries_by_events <- aggregate(data_post_1995$INJURIES,list(data_post_1995$EVTYPE),sum)

injuries_fatalities <- cbind(fatalities_by_events,injuries_by_events$x)

Selecting only the events with at least one fatality

injuries_fatalities_2 <- injuries_fatalities[(injuries_fatalities[,2])>0|(injuries_fatalities[,3])>0,]

Examining only the Event types

print(injuries_fatalities_2$Group.1) 
##   [1] AVALANCHE                BLACK ICE               
##   [3] BLIZZARD                 blowing snow            
##   [5] BRUSH FIRE               COASTAL FLOOD           
##   [7] Coastal Flooding         COASTAL FLOODING        
##   [9] COASTAL FLOODING/EROSION Coastal Storm           
##  [11] COASTAL STORM            COASTALSTORM            
##  [13] Cold                     COLD                    
##  [15] COLD AND SNOW            Cold Temperature        
##  [17] COLD WEATHER             COLD/WIND CHILL         
##  [19] DENSE FOG                DROUGHT                 
##  [21] DROWNING                 DRY MICROBURST          
##  [23] Dust Devil               DUST DEVIL              
##  [25] DUST STORM               EXCESSIVE HEAT          
##  [27] EXCESSIVE SNOW           Extended Cold           
##  [29] Extreme Cold             EXTREME COLD            
##  [31] EXTREME COLD/WIND CHILL  EXTREME WINDCHILL       
##  [33] FALLING SNOW/ICE         FLASH FLOOD             
##  [35] FLOOD                    FOG                     
##  [37] FREEZING DRIZZLE         FREEZING RAIN           
##  [39] Freezing Spray           FROST                   
##  [41] FUNNEL CLOUD             GLAZE                   
##  [43] GUSTY WIND               Gusty winds             
##  [45] Gusty Winds              GUSTY WINDS             
##  [47] HAIL                     HAZARDOUS SURF          
##  [49] HEAT                     Heat Wave               
##  [51] HEAVY RAIN               HEAVY SEAS              
##  [53] HEAVY SNOW               Heavy snow shower       
##  [55] Heavy Surf               HEAVY SURF              
##  [57] Heavy surf and wind      HEAVY SURF/HIGH SURF    
##  [59] HIGH SEAS                High Surf               
##  [61] HIGH SURF                HIGH SWELLS             
##  [63] HIGH WATER               HIGH WIND               
##  [65] HURRICANE                Hurricane Edouard       
##  [67] HURRICANE/TYPHOON        HYPERTHERMIA/EXPOSURE   
##  [69] Hypothermia/Exposure     HYPOTHERMIA/EXPOSURE    
##  [71] ICE ON ROAD              ICE ROADS               
##  [73] ICE STORM                ICY ROADS               
##  [75] LANDSLIDE                LANDSLIDES              
##  [77] LIGHT SNOW               LIGHTNING               
##  [79] Marine Accident          MARINE HIGH WIND        
##  [81] MARINE STRONG WIND       MARINE THUNDERSTORM WIND
##  [83] MARINE TSTM WIND         MIXED PRECIP            
##  [85] Mudslide                 Mudslides               
##  [87] NON-SEVERE WIND DAMAGE   NON TSTM WIND           
##  [89] OTHER                    RAIN/SNOW               
##  [91] RECORD HEAT              RIP CURRENT             
##  [93] RIP CURRENTS             RIVER FLOOD             
##  [95] River Flooding           RIVER FLOODING          
##  [97] ROGUE WAVE               ROUGH SEAS              
##  [99] ROUGH SURF               SMALL HAIL              
## [101] Snow                     SNOW                    
## [103] SNOW AND ICE             SNOW SQUALL             
## [105] Snow Squalls             STORM SURGE             
## [107] STORM SURGE/TIDE         STRONG WIND             
## [109] Strong Winds             STRONG WINDS            
## [111] THUNDERSTORM             THUNDERSTORM WIND       
## [113] THUNDERSTORM WIND (G40)  TIDAL FLOODING          
## [115] TORNADO                  Torrential Rainfall     
## [117] TROPICAL STORM           TSTM WIND               
## [119] TSTM WIND (G35)          TSTM WIND (G40)         
## [121] TSTM WIND (G45)          TSTM WIND/HAIL          
## [123] TSUNAMI                  TYPHOON                 
## [125] UNSEASONABLY WARM        URBAN/SML STREAM FLD    
## [127] WARM WEATHER             WATERSPOUT              
## [129] Whirlwind                WILD/FOREST FIRE        
## [131] WILDFIRE                 WIND                    
## [133] WINDS                    WINTER STORM            
## [135] WINTER WEATHER           WINTER WEATHER MIX      
## [137] WINTER WEATHER/MIX       WINTRY MIX              
## 985 Levels:    HIGH SURF ADVISORY  COASTAL FLOOD ... WND

The events shown have a lot of causes which can be considered as very similar. Next, we create new groups with closer events to reduce the number of inputs. Then, we obtain results across the new groups created.

injuries_fatalities_2$Group.1 <- gsub("(.*)COLD(.*)","COLD",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)Cold(.*)","COLD",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)SURF(.*)","SURF",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)Surf(.*)","SURF",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)Tornado(.*)","TORNADO",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)TORNADO(.*)","TORNADO",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)THUNDER(.*)TORM(.*)","THUNDERSTORM",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)Thunder(.*)","THUNDERSTORM",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)TSTM(.*)","THUNDERSTORM",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)FLOOD(.*)","FLOOD",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)Flood(.*)","FLOOD",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)HURRICANE(.*)","HURRICANE",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)Hurricane(.*)","HURRICANE",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)LIGHTNING(.*)","LIGHTNING",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)FIRE(.*)","FIRE",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)[Ww]ind(.*)","WIND",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)WIND(.*)","WIND",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)Heat(.*)","HEAT",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)HEAT(.*)","HEAT",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)Dust(.*)","DUST",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)DUST(.*)","DUST",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)MIX(.*)","WINTER WEATHER/MIX",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)RIP CURRENT(.*)","RIP CURRENT",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)ICE(.*)","ICE",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)ICY(.*)","ICE",injuries_fatalities_2$Group.1)
injuries_fatalities_2$Group.1 <- gsub("(.*)[Ss][Nn][Oo][Ww](.*)","SNOW",injuries_fatalities_2$Group.1)

fatalities_new <- aggregate(injuries_fatalities_2$x,list(injuries_fatalities_2$Group.1),sum)

injuries_new <- aggregate(injuries_fatalities_2[,3],list(injuries_fatalities_2$Group.1),sum)

injuries_fatalities_def <- cbind(fatalities_new,injuries_new[,2])

colnames(injuries_fatalities_def) <- c("Event","fatalities","injuries")

Here we can see a summary of the new results

print(injuries_fatalities_def)
##                    Event fatalities injuries
## 1              AVALANCHE        223      156
## 2               BLIZZARD         70      385
## 3          Coastal Storm          0        1
## 4          COASTAL STORM          3        1
## 5           COASTALSTORM          1        0
## 6                   COLD        372      127
## 7              DENSE FOG          9      143
## 8                DROUGHT          0        4
## 9               DROWNING          1        0
## 10        DRY MICROBURST          3       25
## 11                  DUST         13      415
## 12                  FIRE         87     1458
## 13                 FLOOD       1309     8441
## 14                   FOG         60      712
## 15      FREEZING DRIZZLE          2       13
## 16         FREEZING RAIN          2        0
## 17        Freezing Spray          1        0
## 18                 FROST          1        3
## 19          FUNNEL CLOUD          0        1
## 20                 GLAZE          1      212
## 21                  HAIL          7      713
## 22                  HEAT       2036     7683
## 23            HEAVY RAIN         94      230
## 24            HEAVY SEAS          1        0
## 25             HIGH SEAS          3        7
## 26           HIGH SWELLS          1        0
## 27            HIGH WATER          3        0
## 28             HURRICANE        125     1323
## 29 HYPERTHERMIA/EXPOSURE          1        0
## 30  Hypothermia/Exposure          4        0
## 31  HYPOTHERMIA/EXPOSURE          3        0
## 32                   ICE         90      366
## 33             LANDSLIDE         37       52
## 34            LANDSLIDES          1        1
## 35             LIGHTNING        651     4141
## 36       Marine Accident          1        2
## 37              Mudslide          4        2
## 38             Mudslides          1        0
## 39                 OTHER          0        4
## 40           RIP CURRENT        542      503
## 41            ROGUE WAVE          0        2
## 42            ROUGH SEAS          8        5
## 43            SMALL HAIL          0       10
## 44                  SNOW        118      754
## 45           STORM SURGE          2       37
## 46      STORM SURGE/TIDE         11        5
## 47                  SURF        142      240
## 48          THUNDERSTORM        398     5164
## 49               TORNADO       1511    20667
## 50   Torrential Rainfall          0        4
## 51        TROPICAL STORM         57      338
## 52               TSUNAMI         33      129
## 53               TYPHOON          0        5
## 54     UNSEASONABLY WARM          0       17
## 55  URBAN/SML STREAM FLD         28       79
## 56          WARM WEATHER          0        2
## 57            WATERSPOUT          2        2
## 58                  WIND        404     1513
## 59          WINTER STORM        191     1292
## 60        WINTER WEATHER         33      343
## 61    WINTER WEATHER/MIX         31      243

And the last pace is ordering the results in decreasing order of injuried people and dead people. We consider only the 15 most harmful events considered by our new groups

injuries_fatalities_def <- injuries_fatalities_def[order(injuries_fatalities_def$injuries,injuries_fatalities_def$fatalities,decreasing=TRUE),]
most_harmful_personal <- head(injuries_fatalities_def,15)
print(most_harmful_personal)
##           Event fatalities injuries
## 49      TORNADO       1511    20667
## 13        FLOOD       1309     8441
## 22         HEAT       2036     7683
## 48 THUNDERSTORM        398     5164
## 35    LIGHTNING        651     4141
## 58         WIND        404     1513
## 12         FIRE         87     1458
## 28    HURRICANE        125     1323
## 59 WINTER STORM        191     1292
## 44         SNOW        118      754
## 21         HAIL          7      713
## 14          FOG         60      712
## 40  RIP CURRENT        542      503
## 11         DUST         13      415
## 2      BLIZZARD         70      385

Processing the data for calculating the economic impact

To make the required computations, we use the data from 1995, for the reasons explained previously. Using the dataset from 1995 as a source data, first we filter out only the events which cause important economic damage, corresponding to a PROPDMG and CROPDMG Columns with a value greater than zero

data_economic <- data_post_1995[(data_post_1995[,25]>0)|(data_post_1995[,27]>0),]

We have to interpret the PROPDMGEXP and CROPDMGEXP as a correct multiplyer of PROPDMG and CRPDMG. To do this, now we change the levels of the factors corresponding to PROPDMGEXP and CROPDMGEXP

levels(data_economic$PROPDMGEXP)
##  [1] ""  "-" "?" "+" "0" "1" "2" "3" "4" "5" "6" "7" "8" "B" "h" "H" "K"
## [18] "m" "M"
levels(data_economic$CROPDMGEXP)
## [1] ""  "?" "0" "2" "B" "k" "K" "m" "M"
levels(data_economic$PROPDMGEXP) <- c("0","1","1","1","1","10","100","1000","10000","100000","1000000","10000000","100000000","1000000000","100","100","1000","1000000","1000000")
levels(data_economic$CROPDMGEXP) <- c("0","1","1","100","1000000000","1000","1000","1000000","1000000")

head(data_economic)
##        STATE__          BGN_DATE    BGN_TIME TIME_ZONE COUNTY
## 248768       1  1/6/1996 0:00:00 08:00:00 PM       CST      1
## 248769       1 1/11/1996 0:00:00 06:35:00 PM       CST     31
## 248770       1 1/11/1996 0:00:00 06:45:00 PM       CST     31
## 248771       1 1/11/1996 0:00:00 07:05:00 PM       CST     45
## 248772       1 1/11/1996 0:00:00 07:38:00 PM       CST     67
## 248774       1 1/18/1996 0:00:00 06:00:00 PM       CST      1
##                    COUNTYNAME STATE       EVTYPE BGN_RANGE BGN_AZI
## 248768             ALZ001>038    AL WINTER STORM         0        
## 248769                 COFFEE    AL      TORNADO         5       N
## 248770                 COFFEE    AL    TSTM WIND         0        
## 248771                   DALE    AL    TSTM WIND         0        
## 248772                  HENRY    AL    TSTM WIND         0        
## 248774 ALZ001>018 - 020 - 022    AL    HIGH WIND         0        
##        BGN_LOCATI          END_DATE    END_TIME COUNTY_END COUNTYENDN
## 248768             1/7/1996 0:00:00 03:00:00 PM          0         NA
## 248769    KINSTON 1/11/1996 0:00:00 06:36:00 PM          0         NA
## 248770 ENTERPRISE 1/11/1996 0:00:00 06:45:00 PM          0         NA
## 248771   PINCKARD 1/11/1996 0:00:00 07:05:00 PM          0         NA
## 248772   HEADLAND 1/11/1996 0:00:00 07:38:00 PM          0         NA
## 248774            1/19/1996 0:00:00 05:00:00 AM          0         NA
##        END_RANGE END_AZI END_LOCATI LENGTH WIDTH  F MAG FATALITIES
## 248768         0                         0     0 NA   0          0
## 248769         5       N    KINSTON      1    75  1   0          0
## 248770         0         ENTERPRISE      0     0 NA   0          0
## 248771         0           PINCKARD      0     0 NA   0          0
## 248772         0           HEADLAND      0     0 NA   0          0
## 248774         0                         0     0 NA  40          0
##        INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO
## 248768        0     380       1000      38       1000 BMX
## 248769        0     100       1000       0          0 TAE
## 248770        0       3       1000       0          0 TAE
## 248771        0       5       1000       0          0 TAE
## 248772        0       2       1000       0          0 TAE
## 248774        0     400       1000       0          0 BMX
##                STATEOFFIC
## 248768   ALABAMA, Central
## 248769 ALABAMA, Southeast
## 248770 ALABAMA, Southeast
## 248771 ALABAMA, Southeast
## 248772 ALABAMA, Southeast
## 248774   ALABAMA, Central
##                                                                                                                                                                                                                                                                                                                                                                                                     ZONENAMES
## 248768 LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN - MARSHALL - JACKSON - DEKALB - MARION - LAMAR - FAYETTE - WINSTON - WALKER - CULLMAN - BLOUNT - ETOWAH - CALHOUN - CHEROKEE - CLEBURNE - PICKENS - TUSCALOOSA - JEFFERSON - SHELBY - ST. CLAIR - TALLADEGA - CLAY - RANDOLPH - SUMTER - GREENE - HALE - PERRY - BIBB - CHILTON - COOSA - TALLAPOOSA - CHAMBERS
## 248769                                                                                                                                                                                                                                                                                                                                                                                                       
## 248770                                                                                                                                                                                                                                                                                                                                                                                                       
## 248771                                                                                                                                                                                                                                                                                                                                                                                                       
## 248772                                                                                                                                                                                                                                                                                                                                                                                                       
## 248774                                                                                                                                                                                    LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN - MARSHALL - JACKSON - DEKALB - MARION - LAMAR - FAYETTE - WINSTON - WALKER - CULLMAN - BLOUNT - ETOWAH - CHEROKEE - PICKENS
##        LATITUDE LONGITUDE LATITUDE_E LONGITUDE_
## 248768        0         0          0          0
## 248769     3116      8608       3116       8608
## 248770     3119      8551       3119       8551
## 248771     3119      8533       3119       8533
## 248772     3121      8521       3121       8521
## 248774        0         0          0          0
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            REMARKS
## 248768 A winter storm brought a mixture of freezing rain, sleet, and snow to the northern two-thirds of Alabama.  Precipitation began as freezing rain and sleet but quickly changed to snow.  The precipitation coated roads and caused serious travel problems across the northern sections of thestate that lasted into Monday morning (the 8th).  Some higher elevations of the northeast corner of Alabama had travel problems into Tuesday.  Amounts were generally light with the highest snowfall reported at Huntsville International Airport with 2 inches.  Most other locations across North Alabama reported one-quarter of an inch to an inch and a half.  On Sunday the 7th, one fatality occurred in an automobile/train collision in Calhoun County that was attributed to icy roads.  The teenage driver of the car was not wearing a seat belt and was thrown from the vehicle.
## 248769                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 A tornado destroyed 4 house trailers that were unoccupied. Debris was scattered for about 1 mile, according to county emergency management.
## 248770                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Several trees were blown down and two backyard sheds were destroyed according to newspaper reports and county emergency management.
## 248771                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      County emergency management confirmed that three sheds were destroyed, and several houses received superficial damage.
## 248772                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      County emergency management reported that a porch roof was lifted off a home and a shed was destroyed.
## 248774                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             High wind over the northern third of Alabama generally along a cold front caused widespread scattered damage.  Damage was primarily to downed trees, limbs, and power lines but some roof damage occurred in several locations.
##        REFNUM year
## 248768 248768 1996
## 248769 248769 1996
## 248770 248770 1996
## 248771 248771 1996
## 248772 248772 1996
## 248774 248774 1996

Now we are creating a new variable which summarizes the total damage

total_economic_damage <- data_economic$PROPDMG * (as.numeric(as.character(data_economic$PROPDMGEXP))) + data_economic$CROPDMG*(as.numeric(as.character(data_economic$CROPDMGEXP)))

We are only interested in the new total damage variable and the type of event. For this reason, we create a new subset with only the two columns mentioned

economic_damage_event <- cbind(as.character(data_economic$EVTYPE),total_economic_damage)
colnames(economic_damage_event) <- c("Event","Damage")

Next step is group the results by Event Types

economic_damage_by_event <- aggregate(as.numeric(economic_damage_event[,2]),list(economic_damage_event[,1]),sum)

And then, as groups are very similar to the used on the personal damage case, we use ALMOST the same simplifying of groups. Here we add a processing for the name groups similar to “Storm Surge” to have only one group

economic_damage_by_event$Group.1 <- gsub("(.*)COLD(.*)","COLD",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)Cold(.*)","COLD",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)SURF(.*)","SURF",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)Surf(.*)","SURF",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)Tornado(.*)","TORNADO",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)TORNADO(.*)","TORNADO",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)THUNDER(.*)TORM(.*)","THUNDERSTORM",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)Thunder(.*)","THUNDERSTORM",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)TSTM(.*)","THUNDERSTORM",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)FLOOD(.*)","FLOOD",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)Flood(.*)","FLOOD",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)HURRICANE(.*)","HURRICANE",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)Hurricane(.*)","HURRICANE",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)LIGHTNING(.*)","LIGHTNING",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)FIRE(.*)","FIRE",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)[Ww]ind(.*)","WIND",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)WIND(.*)","WIND",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)Heat(.*)","HEAT",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)HEAT(.*)","HEAT",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)Dust(.*)","DUST",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)DUST(.*)","DUST",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)MIX(.*)","WINTER WEATHER/MIX",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)RIP CURRENT(.*)","RIP CURRENT",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)ICE(.*)","ICE",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)ICY(.*)","ICE",economic_damage_by_event$Group.1)
economic_damage_by_event$Group.1 <- gsub("(.*)[Ss][Nn][Oo][Ww](.*)","SNOW",economic_damage_by_event$Group.1)
#Extra modification
economic_damage_by_event$Group.1 <- gsub("(.*)STORM SURGE(.*)","STORM SURGE",economic_damage_by_event$Group.1)

damage_new <- aggregate(economic_damage_by_event$x,list(economic_damage_by_event$Group.1),sum)

colnames(damage_new) <- c("Event","Damage")

print(damage_new)
##                     Event       Damage
## 1     AGRICULTURAL FREEZE     28820000
## 2  ASTRONOMICAL HIGH TIDE      9425000
## 3   ASTRONOMICAL LOW TIDE       320000
## 4               AVALANCHE      3711800
## 5           Beach Erosion       100000
## 6                BLIZZARD    532718950
## 7         COASTAL EROSION       766000
## 8           Coastal Storm        50000
## 9                    COLD   1370817900
## 10              DAM BREAK      1002000
## 11        Damaging Freeze     34130000
## 12        DAMAGING FREEZE      8000000
## 13              DENSE FOG      7319000
## 14            DENSE SMOKE       100000
## 15              DOWNBURST         2000
## 16                DROUGHT  14413667000
## 17         DRY MICROBURST      1747600
## 18                   DUST      9257630
## 19            Early Frost     42000000
## 20                   FIRE   8162704630
## 21                  FLOOD 166047107120
## 22                    FOG     13145500
## 23                 Freeze     10500000
## 24                 FREEZE    146425000
## 25       Freezing drizzle        15000
## 26       Freezing Drizzle        55000
## 27       FREEZING DRIZZLE        35000
## 28           FREEZING FOG      2182000
## 29          Freezing Rain        35000
## 30          FREEZING RAIN       591000
## 31                  FROST        15000
## 32           Frost/Freeze      1100000
## 33           FROST/FREEZE   1103566000
## 34           FUNNEL CLOUD       134100
## 35                  Glaze        90000
## 36                  GLAZE        60000
## 37                   HAIL  17071172870
## 38            HARD FREEZE     12900000
## 39                   HEAT    501822200
## 40             HEAVY RAIN   1313034240
## 41              HIGH SEAS        15000
## 42            HIGH SWELLS         5000
## 43              HURRICANE  86467941810
## 44                    ICE   3658252010
## 45   Ice jam flood (minor         1000
## 46              LANDSLIDE    344595000
## 47             LANDSLIDES         5000
## 48              Landslump       570000
## 49              LANDSPOUT         7000
## 50    LIGHT FREEZING RAIN       451000
## 51              LIGHTNING    749975520
## 52        Marine Accident        50000
## 53            MARINE HAIL         4000
## 54             Microburst        20000
## 55    Mixed Precipitation       235000
## 56              MUD SLIDE       100100
## 57               MUDSLIDE      1225000
## 58                  Other        50000
## 59                  OTHER      1039900
## 60                   RAIN       550000
## 61            RIP CURRENT       163000
## 62             ROCK SLIDE       150000
## 63                 SEICHE       980000
## 64             SMALL HAIL     20863000
## 65                   SNOW    753113640
## 66            STORM SURGE  47835579000
## 67                   SURF    110374500
## 68           THUNDERSTORM   8936415880
## 69                TORNADO  24900370720
## 70    TROPICAL DEPRESSION      1737000
## 71         TROPICAL STORM   8320186550
## 72                TSUNAMI    144082000
## 73                TYPHOON    601055000
## 74      UNSEASONABLY WARM        10000
## 75        UNSEASONAL RAIN     10000000
## 76   URBAN/SML STREAM FLD     66797750
## 77           VOLCANIC ASH       500000
## 78             WATERSPOUT      5730200
## 79         WET MICROBURST        35000
## 80                   WIND   6148911240
## 81           WINTER STORM   1544687250
## 82         WINTER WEATHER     35866000
## 83     WINTER WEATHER/MIX      6997000
## 84             Wintry Mix         2500

And the last pace is ordering the results in decreasing order of economic damaged produced by the events. We consider only the 15 most harmful events considered by our new groups

damage_new <- damage_new[order(damage_new$Damage,decreasing=TRUE),]
most_harmful_economic <- head(damage_new,15)
print(most_harmful_economic)
##             Event       Damage
## 21          FLOOD 166047107120
## 43      HURRICANE  86467941810
## 66    STORM SURGE  47835579000
## 69        TORNADO  24900370720
## 37           HAIL  17071172870
## 16        DROUGHT  14413667000
## 68   THUNDERSTORM   8936415880
## 71 TROPICAL STORM   8320186550
## 20           FIRE   8162704630
## 80           WIND   6148911240
## 44            ICE   3658252010
## 81   WINTER STORM   1544687250
## 9            COLD   1370817900
## 40     HEAVY RAIN   1313034240
## 33   FROST/FREEZE   1103566000

Results

Dead people by events

First of all we are going to show the 15 most harmful events condidering the amount of deaths involved in (number of people)

library("lattice")

barchart(most_harmful_personal$Event~most_harmful_personal$fatalities,xlab="Dead people by event",ylab="Events")

The top3 harmful events, considering the amount of people directly dead is:

  1. HEAT
  2. TORNADO
  3. FLOOD

Injuried people by events

Our second plot shows the 15 most harmful events condidering the amount of injuried people as a consequence of the event

barchart(most_harmful_personal$Event~most_harmful_personal$injuries,xlab="Injuried people by event",ylab="Events")

The top3 harmful events, considering the amount of people injuried is:

  1. TORNADO
  2. HEAT
  3. FLOOD

Economic impact caused by events

Now the 15 most harmful events condidering the total economic impact (in dollars) adding corporal and property damages

barchart(most_harmful_economic$Event~most_harmful_economic$Damage,xlab="Economic damage caused by event",ylab="Events")

The top3 harmful events, considering the economic impact caused is:

  1. FLOOD
  2. HURRICANE
  3. STORM SURGE