This report present the analisis on the impact of different weather events on public health and economy according to the storm database from the U.S. National Oceanic and Atmospheric Administration’s (NOAA) from 1950 - 2011. A key concern was base on many severe events in which the result can be in fatalities, injuries, and property damage, and preventing.
echo = TRUE # Allow code to always be displayed
options(scipen = 1) # Turn off scientific notation.
library(ggplot2)
library(plyr)
require(gridExtra)
## Loading required package: gridExtra
First, load the data and read .csv file.
StormData <- read.csv("repdata_data_StormData.csv", sep = ",")
dim(StormData)
## [1] 902297 37
head(StormData)
## STATE__ BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1 1 4/18/1950 0:00:00 0130 CST 97 MOBILE AL
## 2 1 4/18/1950 0:00:00 0145 CST 3 BALDWIN AL
## 3 1 2/20/1951 0:00:00 1600 CST 57 FAYETTE AL
## 4 1 6/8/1951 0:00:00 0900 CST 89 MADISON AL
## 5 1 11/15/1951 0:00:00 1500 CST 43 CULLMAN AL
## 6 1 11/15/1951 0:00:00 2000 CST 77 LAUDERDALE AL
## EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END
## 1 TORNADO 0 0
## 2 TORNADO 0 0
## 3 TORNADO 0 0
## 4 TORNADO 0 0
## 5 TORNADO 0 0
## 6 TORNADO 0 0
## COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1 NA 0 14.0 100 3 0 0
## 2 NA 0 2.0 150 2 0 0
## 3 NA 0 0.1 123 2 0 0
## 4 NA 0 0.0 100 2 0 0
## 5 NA 0 0.0 150 2 0 0
## 6 NA 0 1.5 177 2 0 0
## INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1 15 25.0 K 0
## 2 0 2.5 K 0
## 3 2 25.0 K 0
## 4 2 2.5 K 0
## 5 2 2.5 K 0
## 6 6 2.5 K 0
## LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1 3040 8812 3051 8806 1
## 2 3042 8755 0 0 2
## 3 3340 8742 0 0 3
## 4 3458 8626 0 0 4
## 5 3412 8642 0 0 5
## 6 3450 8748 0 0 6
The result will be divided base on fatalities and injuries. First, sum of all the facilities caused by an specific event. Then, present data decreasing order and take the top 10.
Sum_Fatalities <- aggregate(StormData$FATALITIES, by = list(StormData$EVTYPE), "sum")
names(Sum_Fatalities) <- c("Event", "Fatalities")
Sum_Fatalities <- Sum_Fatalities[order(-Sum_Fatalities$Fatalities), ][1:10, ]
Sum_Fatalities
## Event 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
Continue the step base on injuries
Sum_Injuries <- aggregate(StormData$INJURIES, by = list(StormData$EVTYPE), "sum")
names(Sum_Injuries) <- c("Event", "Injuries")
Sum_Injuries <- Sum_Injuries[order(-Sum_Injuries$Injuries), ][1:10, ]
Sum_Injuries
## Event 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
Then, Plot both the data
par(mfrow = c(1, 2), mar = c(12, 5, 3, 2), mgp = c(3, 1, 0), cex = 0.8, las = 3)
barplot(Sum_Fatalities$Fatalities, names.arg = Sum_Fatalities$Event, col = 'green',
main = 'Top 10 Weather Events for Fatalities', ylab = 'Number of Fatalities')
barplot(Sum_Injuries$Injuries, names.arg = Sum_Injuries$Event, col = 'yellow',
main = 'Top 10 Weather Events for Injuries', ylab = 'Number of Injuries')
The following plot shows the most severe weather event have the gratest economic consequences since 1950s.
library(ggplot2)
library(gridExtra)
# Set the levels in order
Prop1 <- ggplot(data=prop_dmg_events,
aes(x=reorder(EVTYPE, prop_dmg), y=log10(prop_dmg), fill=prop_dmg )) +
geom_bar(stat="identity") +
coord_flip() +
xlab("Event type") +
ylab("Property damage in dollars (log-scale)") +
theme(legend.position="none")
Crop1 <- ggplot(data=crop_dmg_events,
aes(x=reorder(EVTYPE, crop_dmg), y=crop_dmg, fill=crop_dmg)) +
geom_bar(stat="identity") +
coord_flip() +
xlab("Event type") +
ylab("Crop damage in dollars") +
theme(legend.position="none")
grid.arrange(Prop1, Crop1)
Interm of crop damage, drouht is the most severe weather event. This caused of more than 10 billion dollars damage for the last half century.