Weather events pose a potent threat human life. Abnormal events (i.e. tornado, hail) can burden human and economic health in the United States. In this document, we analyze Storm Data from the National Weather Service. Data analysis was conducted to determine the amount of injuries and fatalities from each type of weather event. Economic health was assessed by reviewing crop and property damage statistics. We found that a handful of weather related events are responsible for burdening human and economic health. Tornados are the top weather event that causes human injuries, human fatalities, and property damage. Hail is the most common wether event that causes crop damage. The analysis shows that a weather events cause significant damage, and the effects may be lessened by passing legislation aimed at these events.
First, lets download the data and input it into RStudio.
url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(url, destfile = "/Users/joshuastein/Desktop/hello-world/ReproducibleResearch/CourseProject2/repdata_data_StormData.csv.bz2", mode = "wb")
data <- read.csv("/Users/joshuastein/Desktop/hello-world/ReproducibleResearch/CourseProject2/repdata_data_StormData.csv.bz2")
Now, let’s process the data. Let’s first create a dataset to investigate event type on human health.
humanhealthdatafat <- aggregate(FATALITIES ~ EVTYPE, data = data, FUN = sum)
humanhealthdatainj <- aggregate(INJURIES ~ EVTYPE, data = data, FUN = sum)
The dataset was ordered based on the number of fatalities or injuries and only the top 10 events were taken for figure generation.
orderedfatdata <- humanhealthdatafat[order(humanhealthdatafat$FATALITIES, decreasing = TRUE), ]
orderedfatdatatop10 <- orderedfatdata[1:10,]
orderedinjdata <- humanhealthdatainj[order(humanhealthdatainj$INJURIES, decreasing = TRUE), ]
orderedinjdatatop10 <- orderedinjdata[1:10,]
Now, let’s investigate weather event on economic health by assessing property damage and crop. First, we need to convert property damage value into a numerical number.
i <- 1
while (i < length(data)){
if(data$PROPDMGEXP[i] == "K"){
data$PROPDMG[i] <- data$PROPDMG[i] * 1000
}
if(data$PROPDMGEXP[i] == "M"){
data$PROPDMG[i] <- data$PROPDMG[i] * 1000000
}
if(data$CROPDMGEXP[i] == "K"){
data$CROPDMG[i] <- data$CROPDMG[i] * 1000
}
if(data$CROPDMGEXP[i] == "M"){
data$CROPDMG[i] <- data$CROPDMG[i] * 1000000
}
i <- i + 1
}
And for determining the top 10.
ecohealthdataprop <- aggregate(PROPDMG ~ EVTYPE, data = data, FUN = sum)
ecohealthdatacrop <- aggregate(CROPDMG ~ EVTYPE, data = data, FUN = sum)
orderedpropdata <- ecohealthdataprop[order(ecohealthdataprop$PROPDMG, decreasing = TRUE), ]
orderedpropdatatop10 <- orderedpropdata[1:10,]
orderedcropdata <- ecohealthdatacrop[order(ecohealthdatacrop$CROPDMG, decreasing = TRUE), ]
orderedcropdatatop10 <- orderedcropdata[1:10,]
Let’s first identify the weather events that are most harmful to human health. We can begin by looking at the number of fatalities.
print(orderedfatdatatop10)
## EVTYPE FATALITIES
## 834 TORNADO 5633
## 130 EXCESSIVE HEAT 1903
## 153 FLASH FLOOD 978
## 275 HEAT 937
## 464 LIGHTNING 816
## 856 TSTM WIND 504
## 170 FLOOD 470
## 585 RIP CURRENT 368
## 359 HIGH WIND 248
## 19 AVALANCHE 224
Here, we see that tornado constitutes just under half the total fatalities. Similar analysis will be conducted for injuries.
print(orderedinjdatatop10)
## EVTYPE INJURIES
## 834 TORNADO 91346
## 856 TSTM WIND 6957
## 170 FLOOD 6789
## 130 EXCESSIVE HEAT 6525
## 464 LIGHTNING 5230
## 275 HEAT 2100
## 427 ICE STORM 1975
## 153 FLASH FLOOD 1777
## 760 THUNDERSTORM WIND 1488
## 244 HAIL 1361
The weather events with the next highest fatalities is excessive heat, flash flood, heat, and lightning. We see that tornado is the number one cause of injuries, aligning with the number of fatalities. Next includes wind, flood, excessive heat, and lightening. While these events are found on the number of fatalities, their ordering has changed. Now, let’s visualize with a piechart.
par(mfrow = c(1, 2))
pie(orderedfatdatatop10$FATALITIES, labels = orderedfatdatatop10$EVTYPE, main = "Number of Fatalities")
pie(orderedinjdatatop10$INJURIES, labels = orderedinjdatatop10$EVTYPE, main = "Number of Injuries")
Tornado overwhelmingly causes more injuries and fatalities. It appears that tornados are the most harmful wheather event to human health. Let’s see if the same trend holds true for economic health.
print(orderedpropdatatop10)
## EVTYPE PROPDMG
## 834 TORNADO 11713748.2
## 153 FLASH FLOOD 1420124.6
## 856 TSTM WIND 1335965.6
## 170 FLOOD 899938.5
## 760 THUNDERSTORM WIND 876844.2
## 244 HAIL 688693.4
## 464 LIGHTNING 603351.8
## 786 THUNDERSTORM WINDS 446293.2
## 359 HIGH WIND 324731.6
## 972 WINTER STORM 132720.6
Tornados overwhelming cause property damage. Now let’s look at crop damage.
print(orderedcropdatatop10)
## EVTYPE CROPDMG
## 244 HAIL 579596.28
## 153 FLASH FLOOD 179200.46
## 170 FLOOD 168037.88
## 856 TSTM WIND 109202.60
## 834 TORNADO 100018.52
## 760 THUNDERSTORM WIND 66791.45
## 95 DROUGHT 33898.62
## 786 THUNDERSTORM WINDS 18684.93
## 359 HIGH WIND 17283.21
## 290 HEAVY RAIN 11122.80
Hail is the number one weather event that causes crop damage. Tornado is ranked number 5. Since the data is more distributed, let’s visualize with a pie chart.
pie(orderedcropdatatop10$CROPDMG, labels = orderedcropdatatop10$EVTYPE, main = "Crop Damage")
It’s clear that hail consitutes just under half of all weather event-related crop damage.