This document answers the folowing question from the dataset
The max damage to both property and life was caused by Tornado.
Let’s include some necessary libraries:
library(stringr)
I will assume the .bz2 file has been downloaded from the internet and that you have it present in your current working directory. Following code will read the .bz2 file and store the content in the data frame ‘Rawdset’.
csvF <- bzfile("repdata-data-StormData.csv.bz2")
Rawdset <- read.csv(csvF)
Let’s look at how many event types are there in the dataset.
lev <- levels(Rawdset$EVTYPE)
length(lev)
## [1] 985
Now, that’s a lot of event types, we need to categorize all of them into 47 different event types mentioned in page 6 of the pdf file. Let’s define event code as the numeric code of an event and initialize all to 0
no_of_entries <- length(Rawdset$STATE)
evTypeCode <- numeric(no_of_entries)
Also, let’s make a reference lookup table matching event code to the event type from page 6 of the pdf file.
EvCODE <- c(2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50)
EvName <- c("Astronomical Low Tide", "Avalanche",
"Blizzard", "Coastal Flood", "Cold/Wind Chill",
"Debris Flow", "Dense Fog", "Dense Smoke",
"Drought", "Dust Devil", "Dust Storm",
"Excessive Heat", "Extreme Cold/Wind Chill",
"Flash Flood", "Flood", "Frost/Freeze",
"Funnel Cloud", "Freezing Fog", "Hail",
"Heat", "Heavy Rain", "Heavy Snow",
"High Surf", "High Wind", "Hurricane (Typhoon)",
"Ice Storm", "Lake-Effect Snow", "Lakeshore Flood",
"Lightning", "Marine Hail", "Marine High Wind",
"Marine Strong Wind", "Marine Thunderstorm Wind",
"Rip Current", "Seiche", "Sleet", "Storm Surge/Tide",
"Strong Wind", "Thunderstorm Wind", "Tornado",
"Tropical Depression", "Tropical Storm",
"Tsunami", "Volcanic Ash", "Waterspout",
"Wildfire", "Winter Storm", "Winter Weather")
MyLookUpTable <- data.frame(EventCode = EvCODE, EventName = EvName)
# Print it to show what it looks like:
MyLookUpTable
## EventCode EventName
## 1 2 Astronomical Low Tide
## 2 3 Avalanche
## 3 5 Blizzard
## 4 6 Coastal Flood
## 5 7 Cold/Wind Chill
## 6 8 Debris Flow
## 7 9 Dense Fog
## 8 10 Dense Smoke
## 9 11 Drought
## 10 12 Dust Devil
## 11 13 Dust Storm
## 12 14 Excessive Heat
## 13 15 Extreme Cold/Wind Chill
## 14 16 Flash Flood
## 15 17 Flood
## 16 18 Frost/Freeze
## 17 19 Funnel Cloud
## 18 20 Freezing Fog
## 19 21 Hail
## 20 22 Heat
## 21 23 Heavy Rain
## 22 24 Heavy Snow
## 23 25 High Surf
## 24 26 High Wind
## 25 27 Hurricane (Typhoon)
## 26 28 Ice Storm
## 27 29 Lake-Effect Snow
## 28 30 Lakeshore Flood
## 29 31 Lightning
## 30 32 Marine Hail
## 31 33 Marine High Wind
## 32 34 Marine Strong Wind
## 33 35 Marine Thunderstorm Wind
## 34 36 Rip Current
## 35 37 Seiche
## 36 38 Sleet
## 37 39 Storm Surge/Tide
## 38 40 Strong Wind
## 39 41 Thunderstorm Wind
## 40 42 Tornado
## 41 43 Tropical Depression
## 42 44 Tropical Storm
## 43 45 Tsunami
## 44 46 Volcanic Ash
## 45 47 Waterspout
## 46 48 Wildfire
## 47 49 Winter Storm
## 48 50 Winter Weather
Now let’s say we need to find all the events of type blizzard. We can search the string “blizz” for all the levels, and store the relevant results in a vector. This is done by the following example code.
comp5 <- "([bB][lL][iI][zZ])"
indice5 <- which(complete.cases(str_match(lev, comp5)[,1]))
vals5 <- lev[indice5]
I will now write the code for each such entry. I have made a list of strings that need to be searched for to detect a specific event type among the mentioned ones in the pdf. This is a lengthy code.
comp3 <- "([aA][vV][aA][lL])"
indice3 <- which(complete.cases(str_match(lev, comp3)[,1]))
vals3 <- lev[indice3]
comp5 <- "([bB][lL][iI][zZ])"
indice5 <- which(complete.cases(str_match(lev, comp5)[,1]))
vals5 <- lev[indice5]
comp6 <- "([cC][oO][aA][sS][tT])"
indice6 <- which(complete.cases(str_match(lev, comp6)[,1]))
vals6 <- lev[indice6]
comp7a <- "([cC][oO][lL][dD])"
indice7a <- which(complete.cases(str_match(lev, comp7a)[,1]))
comp7b <- "([wW][iI][nN][dD][ cC][hHcC][iIhH][lLiI])"
indice7b <- which(complete.cases(str_match(lev, comp7b)[,1]))
vals7 <- c(lev[indice7a], lev[indice7b])
comp8 <- "([dD][eE][bB][rR][iI][sS][ fF][lLfF][oOlL])"
indice8 <- which(complete.cases(str_match(lev, comp8)[,1]))
vals8 <- lev[indice8]
comp9 <- "([fF][oO][gG])"
indice9 <- which(complete.cases(str_match(lev, comp9)[,1]))
vals9 <- lev[indice9]
comp10 <- "([sS][mM][oO])"
indice10 <- which(complete.cases(str_match(lev, comp10)[,1]))
vals10 <- lev[indice10]
comp11 <- "([dD][rR][oO][uU])"
indice11 <- which(complete.cases(str_match(lev, comp11)[,1]))
vals11 <- lev[indice11]
comp12 <- "([dD][uU][sS][tT][ dD][dDeE][eEvV])"
indice12 <- which(complete.cases(str_match(lev, comp12)[,1]))
vals12 <- lev[indice12]
comp13 <- "([dD][uU][sS][tT][ sS][sStT][tToO])"
indice13 <- which(complete.cases(str_match(lev, comp13)[,1]))
vals13 <- lev[indice13]
comp14 <- "([eE][xX][tTcC][rReE][eEsS][mMsS][eEiI][ vV][hHeE][ eEhH][aAhHeE])"
indice14 <- which(complete.cases(str_match(lev, comp14)[,1]))
vals14 <- lev[indice14]
comp15 <- "([eE][xX][tTcC][rReE][eEsS][mMsS][eEiI][ vV][cCeE][ cCoO][cCoOlLdD])"
indice15 <- which(complete.cases(str_match(lev, comp15)[,1]))
comp15a <- "([eE][xX][tTcC][rReE][eEsS][mMsS][eEiI][ vV][eEwW][iI])"
indice15a <- which(complete.cases(str_match(lev, comp15a)[,1]))
vals15 <- c(lev[indice15], lev[indice15a])
comp16 <- "([fF][lL][aA][sS][hH])"
indice16 <- which(complete.cases(str_match(lev, comp16)[,1]))
vals16 <- lev[indice16]
#flood, floods, flooding, flooding/heavy rain
vals17 <- c("FLOOD", "flood", "FLOODS", "FLOODING", "FLOODING/HEAVY RAIN")
comp18 <- "([fF][rR][oO][sS][tT])"
indice18 <- which(complete.cases(str_match(lev, comp18)[,1]))
vals18 <- lev[indice18]
comp19 <- "([cC][lL][oO][uU][dD])"
indice19 <- which(complete.cases(str_match(lev, comp19)[,1]))
vals19 <- lev[indice19]
comp20 <- "([fF][rR][eE][eE][zZ][iI][nN][gG][ fF][fFoO][oOgG])"
indice20 <- which(complete.cases(str_match(lev, comp20)[,1]))
comp20a <- "([iI][cC][eE][ fF][fFoO][oOgG])"
indice20a <- which(complete.cases(str_match(lev, comp20a)[,1]))
vals20 <- c(lev[indice20], lev[indice20a])
comp21 <- "([hH][aA][iI][lL])"
indice21 <- which(complete.cases(str_match(lev, comp21)[,1]))
vals21 <- lev[indice21]
comp22 <- "([hH][eE][aA][tT])"
indice22 <- which(complete.cases(str_match(lev, comp22)[,1]))
vals22 <- lev[indice22]
comp23 <- "([hH][eE][aA][vV][yY][ rR][rRaA][aAiI][iInN])"
indice23 <- which(complete.cases(str_match(lev, comp23)[,1]))
vals23 <- lev[indice23]
comp24 <- "([hH][eE][aA][vV][yY][ sS][sSnN][nNoO])"
indice24 <- which(complete.cases(str_match(lev, comp24)[,1]))
vals24 <- lev[indice24]
comp25 <- "([hH][iI][gG][hH][ sS][sSuU][uUrR][rRfF])"
indice25 <- which(complete.cases(str_match(lev, comp25)[,1]))
vals25 <- lev[indice25]
comp26 <- "([hH][iI][gG][hH][ wW][wWiI][iInN])"
indice26 <- which(complete.cases(str_match(lev, comp26)[,1]))
vals26 <- lev[indice26]
comp27 <- "([hH][uU][rR][rR][iI][cC][aA][nN][eE])"
indice27 <- which(complete.cases(str_match(lev, comp27)[,1]))
comp27a <- "([tT][yY][pP])"
indice27a <- which(complete.cases(str_match(lev, comp27a)[,1]))
vals27 <- c(lev[indice27], lev[indice27a])
comp28 <- "([iI][cC][eE][ sS][sStT][tToO])"
indice28 <- which(complete.cases(str_match(lev, comp28)[,1]))
vals28 <- lev[indice28]
comp29 <- "([lL][aA][kK][eE][ -][sSeE][nNfF])"
indice29 <- which(complete.cases(str_match(lev, comp29)[,1]))
vals29 <- lev[indice29]
comp30 <- "([lL][aA][kK][eE][ sS][fFhH][lLoO])"
indice30 <- which(complete.cases(str_match(lev, comp30)[,1]))
vals30 <- lev[indice30]
comp31 <- "([tT][nN][iI][nN][gG])"
indice31 <- which(complete.cases(str_match(lev, comp31)[,1]))
vals31 <- lev[indice31]
comp32 <- "([mM][aA][rR][iI][nN][eE][ hH][hHaA][aAiI][iIlL])"
indice32 <- which(complete.cases(str_match(lev, comp32)[,1]))
vals32 <- lev[indice32]
comp33 <- "([mM][aA][rR][iI][nN][eE][ ][hH][iI][gG][hH])"
indice33 <- which(complete.cases(str_match(lev, comp33)[,1]))
vals33 <- lev[indice33]
comp34 <- "([mM][aA][rR][iI][nN][eE][ ][sS][tT][rR])"
indice34 <- which(complete.cases(str_match(lev, comp34)[,1]))
vals34 <- lev[indice34]
comp35 <- "([mM][aA][rR][iI][nN][eE][ ][tT][sShH][tTuU][mMnN])"
indice35 <- which(complete.cases(str_match(lev, comp35)[,1]))
vals35 <- lev[indice35]
comp36 <- "([cC][uU][rR][rR])"
indice36 <- which(complete.cases(str_match(lev, comp36)[,1]))
vals36 <- lev[indice36]
comp37 <- "([sS][eE][iI])"
indice37 <- which(complete.cases(str_match(lev, comp37)[,1]))
vals37 <- lev[indice37]
comp38 <- "([sS][lL][eE][eE][tT])"
indice38 <- which(complete.cases(str_match(lev, comp38)[,1]))
vals38 <- lev[indice38]
comp39 <- "([hH][iI][gG][hH][ ][tT][iI][dD][eE])"
indice39 <- which(complete.cases(str_match(lev, comp39)[,1]))
comp39a <- "([oO][uU][tT][ ][tT][iI][dD][eE])"
indice39a <- which(complete.cases(str_match(lev, comp39a)[,1]))
comp39b <- "([sS][tT][oO][rR][mM][ ][sS][uU][rR][gG])"
indice39b <- which(complete.cases(str_match(lev, comp39b)[,1]))
vals39 <- c(lev[indice39], lev[indice39a], lev[indice39b])
comp40 <- "([sS][tT][rR][oO][nN][gG][ ][wW][iI][nN])"
indice40 <- which(complete.cases(str_match(lev, comp40)[,1]))
vals40 <- lev[indice40]
comp41 <- "([tT][hHsS][uUtT][nNmM][ dD])"
indice41 <- which(complete.cases(str_match(lev, comp41)[,1]))
vals41 <- lev[indice41]
comp42 <- "([tT][oO][rR][nN])"
indice42 <- which(complete.cases(str_match(lev, comp42)[,1]))
vals42 <- lev[indice42]
comp43 <- "([dD][eE][pP][rR][eE])"
indice43 <- which(complete.cases(str_match(lev, comp43)[,1]))
vals43 <- lev[indice43]
comp44 <- "([tT][rR][oO][pP][iI][cC][aA][lL][ ][sS][tT][oO])"
indice44 <- which(complete.cases(str_match(lev, comp44)[,1]))
vals44 <- lev[indice44]
comp45 <- "([nN][aA][mM][iI])"
indice45 <- which(complete.cases(str_match(lev, comp45)[,1]))
vals45 <- lev[indice45]
comp46 <- "([vV][oO][lL][cC][aA][nN][iI][cC][ ][aA][sS][hH])"
indice46 <- which(complete.cases(str_match(lev, comp46)[,1]))
vals46 <- lev[indice46]
comp47 <- "([sS][pP][oO][uU][tT])"
indice47 <- which(complete.cases(str_match(lev, comp47)[,1]))
vals47 <- lev[indice47]
comp48 <- "([fF][iI][rR][eE])"
indice48 <- which(complete.cases(str_match(lev, comp48)[,1]))
vals48 <- lev[indice48]
comp49 <- "([wW][iI][nN][tT][eE][rR][ ][sS][tT][oO][rR])"
indice49 <- which(complete.cases(str_match(lev, comp49)[,1]))
vals49 <- lev[indice49]
comp50 <- "([wW][iI][nN][tT][eE][rR][ ][wW][eE][aA])"
indice50 <- which(complete.cases(str_match(lev, comp50)[,1]))
vals50 <- lev[indice50]
comp2 <- "([aA][sS][tT][rR][oO][nN][oO][mM][iI][cC][aA][lL][ ][lL][oO][wW])"
indice2 <- which(complete.cases(str_match(lev, comp2)[,1]))
vals2 <- lev[indice2]
Let me show you what I’m doing here. Let’s take “Tornado” for example. Look at ‘vals42’ in the above code. I’m literally searching for the string “Torn” and saving all the results that made a match into ‘vals42’. Let’s see what this ‘vals42’ looks like:
vals42
## [1] "COLD AIR TORNADO" "TORNADO"
## [3] "TORNADO DEBRIS" "TORNADO F0"
## [5] "TORNADO F1" "TORNADO F2"
## [7] "TORNADO F3" "TORNADO/WATERSPOUT"
## [9] "TORNADOES" "TORNADOES, TSTM WIND, HAIL"
## [11] "TORNADOS" "TORNDAO"
## [13] "WATERSPOUT-TORNADO" "WATERSPOUT TORNADO"
## [15] "WATERSPOUT/ TORNADO" "WATERSPOUT/TORNADO"
So, you see that some wrongly spelled entries like “TORNDAO” are also taken into our calculation. So far, so good. Now, we need to assign even codes for all the events of the same event type.
First we evaluate length of each string vector, in order to perform computations later.
l2 <- length(vals2); l3 <- length(vals3); l5 <- length(vals5); l6 <- length(vals6);
l7 <- length(vals7); l8 <- length(vals8); l9 <- length(vals9); l10 <- length(vals10);
l11 <- length(vals11); l12 <- length(vals12); l13 <- length(vals13); l14 <- length(vals14);
l15 <- length(vals15); l16 <- length(vals16); l17 <- length(vals17); l18 <- length(vals18);
l19 <- length(vals19); l20 <- length(vals20); l21 <- length(vals21); l22 <- length(vals22);
l23 <- length(vals23); l24 <- length(vals24); l25 <- length(vals25); l26 <- length(vals26);
l27 <- length(vals27); l28 <- length(vals28); l29 <- length(vals29); l30 <- length(vals30);
l31 <- length(vals31);l32 <- length(vals32); l33 <- length(vals33);l34 <- length(vals34);
l35 <- length(vals35);l36 <- length(vals36);l37 <- length(vals37);l38 <- length(vals38);
l39 <- length(vals39); l40 <- length(vals40); l41 <- length(vals41);l42 <- length(vals42);
l43 <- length(vals43);l44 <- length(vals44);l45 <- length(vals45);l46 <- length(vals46);
l47 <- length(vals47);l48 <- length(vals48);l49 <- length(vals49); l50 <- length(vals50)
Now, we write the code to assign event codes for each event type
EVTYPE_Vector <- as.character(Rawdset$EVTYPE)
for (i in 1:l3){
evTypeCode [which(EVTYPE_Vector == vals3[i], TRUE)] <- 3
}
for (i in 1:l5){
evTypeCode [which(EVTYPE_Vector == vals5[i], TRUE)] <- 5
}
for (i in 1:l6){
evTypeCode [which(EVTYPE_Vector == vals6[i], TRUE)] <- 6
}
for (i in 1:l7){
evTypeCode [which(EVTYPE_Vector == vals7[i], TRUE)] <- 7
}
for (i in 1:l8){
evTypeCode [which(EVTYPE_Vector == vals8[i], TRUE)] <- 8
}
for (i in 1:l9){
evTypeCode [which(EVTYPE_Vector == vals9[i], TRUE)] <- 9
}
for (i in 1:l10){
evTypeCode [which(EVTYPE_Vector == vals10[i], TRUE)] <- 10
}
for (i in 1:l11){
evTypeCode [which(EVTYPE_Vector == vals11[i], TRUE)] <- 11
}
for (i in 1:l12){
evTypeCode [which(EVTYPE_Vector == vals12[i], TRUE)] <- 12
}
for (i in 1:l13){
evTypeCode [which(EVTYPE_Vector == vals13[i], TRUE)] <- 13
}
for (i in 1:l14){
evTypeCode [which(EVTYPE_Vector == vals14[i], TRUE)] <- 14
}
for (i in 1:l15){
evTypeCode [which(EVTYPE_Vector == vals15[i], TRUE)] <- 15
}
for (i in 1:l16){
evTypeCode [which(EVTYPE_Vector == vals16[i], TRUE)] <- 16
}
for (i in 1:l17){
evTypeCode [which(EVTYPE_Vector == vals17[i], TRUE)] <- 17
}
for (i in 1:l18){
evTypeCode [which(EVTYPE_Vector == vals18[i], TRUE)] <- 18
}
for (i in 1:l19){
evTypeCode [which(EVTYPE_Vector == vals19[i], TRUE)] <- 19
}
for (i in 1:l20){
evTypeCode [which(EVTYPE_Vector == vals20[i], TRUE)] <- 20
}
for (i in 1:l21){
evTypeCode [which(EVTYPE_Vector == vals21[i], TRUE)] <- 21
}
for (i in 1:l22){
evTypeCode [which(EVTYPE_Vector == vals22[i], TRUE)] <- 22
}
for (i in 1:l23){
evTypeCode [which(EVTYPE_Vector == vals23[i], TRUE)] <- 23
}
for (i in 1:l24){
evTypeCode [which(EVTYPE_Vector == vals24[i], TRUE)] <- 24
}
for (i in 1:l25){
evTypeCode [which(EVTYPE_Vector == vals25[i], TRUE)] <- 25
}
for (i in 1:l26){
evTypeCode [which(EVTYPE_Vector == vals26[i], TRUE)] <- 26
}
for (i in 1:l27){
evTypeCode [which(EVTYPE_Vector == vals27[i], TRUE)] <- 27
}
for (i in 1:l28){
evTypeCode [which(EVTYPE_Vector == vals28[i], TRUE)] <- 28
}
for (i in 1:l29){
evTypeCode [which(EVTYPE_Vector == vals29[i], TRUE)] <- 29
}
for (i in 1:l30){
evTypeCode [which(EVTYPE_Vector == vals30[i], TRUE)] <- 30
}
for (i in 1:l31){
evTypeCode [which(EVTYPE_Vector == vals31[i], TRUE)] <- 31
}
for (i in 1:l36){
evTypeCode [which(EVTYPE_Vector == vals36[i], TRUE)] <- 36
}
for (i in 1:l37){
evTypeCode [which(EVTYPE_Vector == vals37[i], TRUE)] <- 37
}
for (i in 1:l38){
evTypeCode [which(EVTYPE_Vector == vals38[i], TRUE)] <- 38
}
for (i in 1:l39){
evTypeCode [which(EVTYPE_Vector == vals39[i], TRUE)] <- 39
}
for (i in 1:l40){
evTypeCode [which(EVTYPE_Vector == vals40[i], TRUE)] <- 40
}
for (i in 1:l41){
evTypeCode [which(EVTYPE_Vector == vals41[i], TRUE)] <- 41
}
for (i in 1:l42){
evTypeCode [which(EVTYPE_Vector == vals42[i], TRUE)] <- 42
}
for (i in 1:l43){
evTypeCode [which(EVTYPE_Vector == vals43[i], TRUE)] <- 43
}
for (i in 1:l44){
evTypeCode [which(EVTYPE_Vector == vals44[i], TRUE)] <- 44
}
for (i in 1:l45){
evTypeCode [which(EVTYPE_Vector == vals45[i], TRUE)] <- 45
}
for (i in 1:l46){
evTypeCode [which(EVTYPE_Vector == vals46[i], TRUE)] <- 46
}
for (i in 1:l47){
evTypeCode [which(EVTYPE_Vector == vals47[i], TRUE)] <- 47
}
for (i in 1:l48){
evTypeCode [which(EVTYPE_Vector == vals48[i], TRUE)] <- 48
}
for (i in 1:l49){
evTypeCode [which(EVTYPE_Vector == vals49[i], TRUE)] <- 49
}
for (i in 1:l50){
evTypeCode [which(EVTYPE_Vector == vals50[i], TRUE)] <- 50
}
for (i in 1:l32){
evTypeCode [which(EVTYPE_Vector == vals32[i], TRUE)] <- 32
}
for (i in 1:l33){
evTypeCode [which(EVTYPE_Vector == vals33[i], TRUE)] <- 33
}
for (i in 1:l34){
evTypeCode [which(EVTYPE_Vector == vals34[i], TRUE)] <- 34
}
for (i in 1:l35){
evTypeCode [which(EVTYPE_Vector == vals35[i], TRUE)] <- 35
}
for (i in 1:l2){
evTypeCode [which(EVTYPE_Vector == vals2[i], TRUE)] <- 2
}
Ok, now the tough part is done. We have event codes per event. What we need to do is to perform a summation of fatalities, injuries, property damage and crop damages. First of all we need to convert the event code from numeric to factor variable to achieve this. Then it’s very simple, use the aggregate function to add by the factor.
evTypeCode <- as.factor(evTypeCode)
Rawdset["EventCode"] <- evTypeCode
fatal <- aggregate(FATALITIES ~ EventCode, Rawdset, sum)
injuries <- aggregate(INJURIES ~ EventCode, Rawdset, sum)
prop_loss <- aggregate(PROPDMG ~ EventCode, Rawdset, sum)
crop_loss <- aggregate(CROPDMG ~ EventCode, Rawdset, sum)
For fatalities and injuries, let’s plot total fatalities by event code:
plot(fatal$EventCode, fatal$FATALITIES)
plot(injuries$EventCode, injuries$INJURIES)
Let’s evaluate from script which eventCode has the maximum of fatalities and injuries. This is done by following code:
fat_max_event <- fatal$EventCode[which(fatal$FATALITIES == max(fatal$FATALITIES), TRUE)]
inj_max_event <- injuries$EventCode[which(injuries$INJURIES == max(injuries$INJURIES), TRUE)]
Let’s similarly plot the results for Property and Crop Damages:
plot(prop_loss$EventCode, prop_loss$PROPDMG)
plot(crop_loss$EventCode, crop_loss$CROPDMG)
Let’s evaluate from script which evenCode has the maximum property damages:
prop_max_event <- prop_loss$EventCode[which(prop_loss$PROPDMG == max(prop_loss$PROPDMG), TRUE)]
crop_max_event <- crop_loss$EventCode[which(crop_loss$CROPDMG == max(crop_loss$CROPDMG), TRUE)]
We are not done yet. We need to match the event code with the type. For this we look into the look-up table.
# For fatalities to humans, following event was most disastrous:
MyLookUpTable$EventName[which(MyLookUpTable$EventCode ==
as.numeric(as.character(fat_max_event)), TRUE)]
## [1] Tornado
## 48 Levels: Astronomical Low Tide Avalanche Blizzard ... Winter Weather
# For injuries to humans, following event was most disastrous:
MyLookUpTable$EventName[which(MyLookUpTable$EventCode ==
as.numeric(as.character(inj_max_event)), TRUE)]
## [1] Tornado
## 48 Levels: Astronomical Low Tide Avalanche Blizzard ... Winter Weather
# Maximum property damage was caused by the following Event type:
MyLookUpTable$EventName[which(MyLookUpTable$EventCode ==
as.numeric(as.character(prop_max_event)), TRUE)]
## [1] Tornado
## 48 Levels: Astronomical Low Tide Avalanche Blizzard ... Winter Weather
# Maximum crop damages were caused by the following event type:
MyLookUpTable$EventName[which(MyLookUpTable$EventCode ==
as.numeric(as.character(crop_max_event)), TRUE)]
## [1] Hail
## 48 Levels: Astronomical Low Tide Avalanche Blizzard ... Winter Weather
By far, Tornado has the worst impact both on human life as well as property damages.