Synopsis
Weather related hazards cause the lost of many economic resources and human lifes. Hence, it is necessary to execute data based strategies for minimizing the risk associated to these hazards. In the present report we address some general questions regarding what type of weather associated events are more harmful to population and what of them have more economic consquences. With this aim we analyzed the storm data as processed from the data provided in the National Weather Service web page.
Data processing
Reading the data
In the next piece of code dependencies are loaded and data is downloaded and readed.
## loading dependencies
library(lubridate)
## downloading and reading the date
url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(url,destfile = "stormData")
weather.db <- read.csv("stormData",header = TRUE)
Economic losses caused by weather hazards
To address which type of weather have the greatest impact on economic damage we sum the quantity of losses in dollars for each type as follows.
## damage by type
dmgByType <- with(weather.db,tapply(PROPDMG,EVTYPE, FUN = sum, na.rm=TRUE))
dmgByType.sorted <- sort(dmgByType,decreasing=TRUE)
Trends in economic losses related to tornados
I wanted to know the economic impact of the two most destructive weather related hazards types (tornados and flash flood) by year. To do this, I summed the cost in dollars in every type recorded in the years of the record as shown in the next piece of code.
## extracting dates
tornadosByDate <- weather.db[weather.db$EVTYPE=="TORNADO",]
tornadosByDate <- tornadosByDate[,c("BGN_DATE","PROPDMG")]
dates <- tornadosByDate$BGN_DATE
dates <- sub(" 0:.*","",dates)
dates <- as.Date(dates,format="%m/%e/%Y")
years <- year(dates)
## getting the property damage caused by tornados
torByDate <- tapply(tornadosByDate$PROPDMG,sort(years), sum, na.remove=TRUE)
years.tor <- unique(years)
## extracting dates
ffByDate <- weather.db[weather.db$EVTYPE=="FLASH FLOOD",]
ffByDate <- ffByDate[,c("BGN_DATE","PROPDMG")]
dates <- ffByDate$BGN_DATE
dates <- sub(" 0:.*","",dates)
dates <- as.Date(dates,format="%m/%e/%Y")
years <- year(dates)
## getting the property damage caused by flash flood
ffByDate <- tapply(ffByDate$PROPDMG,sort(years), sum, na.remove=TRUE)
years.ff <- unique(years)
Fatalites caused by weather hazards
Another important aspect to measure the impact of weather hazards is the number of fatalities associated to them. To examine this point, I summed the number of fatalities grouped by the type of event as follows.
## fatalities by type
fatByType <- with(weather.db,tapply(FATALITIES,EVTYPE, FUN = sum, na.rm=TRUE))
fatByType.sorted <- sort(fatByType,decreasing=TRUE)
Results
The next plot shows the weather related hazards that causes more economic losses in the records. It can be seen that tornados and flash floods caused the biggest economic losses in the records. Hence, efforces should be focussing in the improvement of strategies to minimize damage associated to this kind of events.
## top 15
top <- 1:15
## plotting
par(mar=c(8,6,2,1))
barplot(dmgByType.sorted[top],
las=2,
log = "y",
cex.names = 0.6,
cex.axis = 0.7,
col = "black",
main = "Economic losses by weather related hazards",
ylab = "Cost in Dollars")
In the following plot losses in dollars by property damage are shown as a function of the year. By inspecting the property damages caused by tornados and flash floods it can be seen that both of the events have a tendency to increase in terms of damage costs which further emphasizes the need of policies to manage such problems. However, because the more recent records are expected to be more complete this increasing behavior should be taked with caution.
par(mfrow=c(1,2),
mar=c(5,5,1,2),
oma=c(0,0,2,0))
plot(sort(years.tor),
torByDate,pch=20,
xlab = "Year",
ylab = "Cost in Dollars",
main = "",
ylim = c(0,155000))
lines(sort(years.tor),torByDate)
abline(lm(torByDate~sort(years.tor)),
col = "steelblue",
lwd = 3)
plot(sort(years.ff),ffByDate,pch=20,
xlab = "Year",
ylab = "",
ylim = c(0,155000),
main = "")
lines(sort(years.ff),ffByDate)
abline(lm(ffByDate~sort(years.ff)),
col = "steelblue",
lwd = 3.5)
title(main="Trends in damage associated to weather hazards",
outer=TRUE)
Next, we plot the top 15 weather related hazards and the number of fatalities recorded in the data. As observed from this plot, in addition to be the most costful weather related hazard tornados also causes the biggest number of victims followed by excessive heat as recorded. It is interesting to note that although heat are not in the top ten of hazards that causes more economic losses is however one of the weather events with more number related falalities which shows that economic damage and fatalities are not necessary related.
par(mar=c(8.5,5,2,1))
barplot(fatByType.sorted[top],
las=2,
log = "y",
cex.names = 0.6,
cex.axis = 0.65,
ylab = "Fatalities",
col = "black",
main = "Weather related fatalities")
Conclusions
In the present report I have adressed the question of which are the weather related hazards with bigger destructive potential and lethality. From the analysis it can be seen that tornados and flash flood are the weather types that cause the biggest economic losses. At the other hand Tornados and excessive heat were the most lethal weather types. Regarding the trends in destructive potential it can be seen that the economic losses were tending to increase over the time analyzed. This report could be used to implement strategies for prevention and warning of weather hazards focussing in the more destructive and lethal as Tornados, flash flood, and excessive heat.