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.
This analysis wants to answer two main questions:
To answer these questions we are going to make use of 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.
For this analysis we are going to make use of the Storm Database provided by the National Weather Service Institution.
First of all, let’s load the database in R:
table <- read.csv("repdata_data_StormData.csv.bz2")
head(table)
## STATE__ BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE EVTYPE
## 1 1 4/18/1950 0:00:00 0130 CST 97 MOBILE AL TORNADO
## 2 1 4/18/1950 0:00:00 0145 CST 3 BALDWIN AL TORNADO
## 3 1 2/20/1951 0:00:00 1600 CST 57 FAYETTE AL TORNADO
## 4 1 6/8/1951 0:00:00 0900 CST 89 MADISON AL TORNADO
## 5 1 11/15/1951 0:00:00 1500 CST 43 CULLMAN AL TORNADO
## 6 1 11/15/1951 0:00:00 2000 CST 77 LAUDERDALE AL TORNADO
## BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END COUNTYENDN
## 1 0 0 NA
## 2 0 0 NA
## 3 0 0 NA
## 4 0 0 NA
## 5 0 0 NA
## 6 0 0 NA
## END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES INJURIES PROPDMG
## 1 0 14.0 100 3 0 0 15 25.0
## 2 0 2.0 150 2 0 0 0 2.5
## 3 0 0.1 123 2 0 0 2 25.0
## 4 0 0.0 100 2 0 0 2 2.5
## 5 0 0.0 150 2 0 0 2 2.5
## 6 0 1.5 177 2 0 0 6 2.5
## PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES LATITUDE LONGITUDE
## 1 K 0 3040 8812
## 2 K 0 3042 8755
## 3 K 0 3340 8742
## 4 K 0 3458 8626
## 5 K 0 3412 8642
## 6 K 0 3450 8748
## LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1 3051 8806 1
## 2 0 0 2
## 3 0 0 3
## 4 0 0 4
## 5 0 0 5
## 6 0 0 6
Let’s get some basic info about this table:
dim(table)
## [1] 902297 37
names(table)
## [1] "STATE__" "BGN_DATE" "BGN_TIME" "TIME_ZONE" "COUNTY"
## [6] "COUNTYNAME" "STATE" "EVTYPE" "BGN_RANGE" "BGN_AZI"
## [11] "BGN_LOCATI" "END_DATE" "END_TIME" "COUNTY_END" "COUNTYENDN"
## [16] "END_RANGE" "END_AZI" "END_LOCATI" "LENGTH" "WIDTH"
## [21] "F" "MAG" "FATALITIES" "INJURIES" "PROPDMG"
## [26] "PROPDMGEXP" "CROPDMG" "CROPDMGEXP" "WFO" "STATEOFFIC"
## [31] "ZONENAMES" "LATITUDE" "LONGITUDE" "LATITUDE_E" "LONGITUDE_"
## [36] "REMARKS" "REFNUM"
Our first objective is to find the relation between natural events and the harm they cause to the population’s health.
Let’s start by merging the events in comparison to the fatalities and injuries:
events <- unique(table$EVTYPE)
fatalities_event_relation <- sapply(split(table$FATALITIES, table$EVTYPE),sum)
injuries_event_relation <- sapply(split(table$INJURIES, table$EVTYPE),sum)
We can then plot the results:
plot(1:length(events), fatalities_event_relation, main="Relation between Events and fatalities", sub = mtext(side = 3, "This graph links Events and fatalities"), xlab="Events", ylab="Fatalities", type="l", col="blue")
plot(1:length(events), injuries_event_relation, main="Relation between Events and injuries", sub = mtext(side = 3, "This graph links Events and injuries"), xlab="Events", ylab="Injuries", type="l", col="blue")
With the help of these two graphs we can clearly see how there probably is one specific event that causes both the most fatalities and the most injuries to the human population in the sampled areas. To check what this specific event is we can examine the two recently created lists (fatalities_event_relation and injuries_event_relation) by searching for a result respectively bigger than 5000 and 80000:
fatalities_event_relation[fatalities_event_relation>5000]
## TORNADO
## 5633
injuries_event_relation[injuries_event_relation>80000]
## TORNADO
## 91346
Thus clearly declaring the Tornado as the major cause of human harm.
Regarding the second question, we can start by associating the events with the property and crop damage they caused. We are going to find the exact sum of money of caused damage (to properties and crops) and then we are going to link both of them with the types of event:
total_cost_prop <- split(table$PROPDMG, table$PROPDMGEXP)
total_prop_sum <- 0
propdmg_process <- c()
counter <- 0
for (i in 1:length(total_cost_prop)) {
for (j in 1:length(total_cost_prop[[i]])) {
if (names(total_cost_prop)[i] == "k" | names(total_cost_prop)[i] == "K") {
total_prop_sum <- total_prop_sum + (total_cost_prop[[i]][j]*1000)
propdmg_process[counter] <- total_prop_sum + (total_cost_prop[[i]][j]*1000)
} else if (names(total_cost_prop)[i] == "m" | names(total_cost_prop)[i] == "M") {
total_prop_sum <- total_prop_sum + (total_cost_prop[[i]][j]*1000000)
propdmg_process[counter] <- total_prop_sum + (total_cost_prop[[i]][j]*1000000)
} else if (names(total_cost_prop)[i] == "b" | names(total_cost_prop)[i] == "B") {
total_prop_sum <- total_prop_sum + (total_cost_prop[[i]][j]*1000000000)
propdmg_process[counter] <- total_prop_sum + (total_cost_prop[[i]][j]*1000000000)
} else {
total_prop_sum <- total_prop_sum + total_cost_prop[[i]][j]
propdmg_process[counter] <- total_prop_sum + total_cost_prop[[i]][j]
}
counter <- counter + 1
}
}
total_prop_sum
## [1] 427318650299
total_cost_crop <- split(table$CROPDMG, table$CROPDMGEXP)
total_crop_sum <- 0
cropdmg_process <- c()
counter <- 0
for (i in 1:length(total_cost_crop)) {
for (j in 1:length(total_cost_crop[[i]])) {
if (names(total_cost_crop)[i] == "k" | names(total_cost_crop)[i] == "K") {
total_crop_sum <- total_crop_sum + (total_cost_crop[[i]][j]*1000)
cropdmg_process[counter] <- total_crop_sum + (total_cost_crop[[i]][j]*1000)
} else if (names(total_cost_crop)[i] == "m" | names(total_cost_crop)[i] == "M") {
total_crop_sum <- total_crop_sum + (total_cost_crop[[i]][j]*1000000)
cropdmg_process[counter] <- total_crop_sum + (total_cost_crop[[i]][j]*1000000)
} else if (names(total_cost_crop)[i] == "b" | names(total_cost_crop)[i] == "B") {
total_crop_sum <- total_crop_sum + (total_cost_crop[[i]][j]*1000000000)
cropdmg_process[counter] <- total_crop_sum + (total_cost_crop[[i]][j]*1000000000)
} else {
total_crop_sum <- total_crop_sum + total_cost_crop[[i]][j]
cropdmg_process[counter] <- total_crop_sum + total_cost_crop[[i]][j]
}
counter <- counter + 1
}
}
total_crop_sum
## [1] 49104192181
property_damage_event_relation <- sapply(split(propdmg_process, table$EVTYPE),sum)
crops_damage_event_relation <- sapply(split(cropdmg_process, table$EVTYPE),sum)
We can then plot the results:
plot(1:length(events), property_damage_event_relation, main="Relation between Events and damages", sub = mtext(side = 3, "This graph links Events and damages"), xlab="Events", ylab="Damages", type="l", lwd=5, col="blue")
par(new=TRUE, yaxt="n")
plot(1:length(events), crops_damage_event_relation, main="", xlab="", ylab="", type="l", col="red", ylim=c(0,max(property_damage_event_relation)))
legend(x="topleft", legend=c("Properties", "Crops"), fill=c("blue", "red"))
The graph clearly shows how properties and crops have a similar peak, which means that the event is probably the same.
property_damage_event_relation[property_damage_event_relation>3e+16]
## HAIL
## 3.857933e+16
crops_damage_event_relation[crops_damage_event_relation>1.21e+15]
## HAIL
## 1.215817e+15
We can conclude this short study by observing how, in the United States and within the scope of the database, tornadoes seem to be the biggest cause of harm for humans, while hail is responsible for the majority of destruction of properties and crops.