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, and preventing such outcomes to the extent possible is a key concern.
This project involves exploring 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.
##Allocation The basic goal of this assignment is to explore NOAA’s storm database and answer some basic questions about severe weather events.
We are going to study which meteorological events are most harmful to the health of the population of the United States and, in turn, which ones affect the most negatively to the economy of the country.
library(ggplot2)
File_data <- "repdata_data_activity/repdata_data_StormData.csv.bz2"
if (!file.exists(File_data)) {download.file(Url_data, File_data, mode = "wb")}
# reading data
data <- read.csv(file = File_data, header=TRUE, sep=",")
injuries <- aggregate(INJURIES ~ EVTYPE, data= data, FUN = sum)
injuries <- injuries[injuries$INJURIES>mean(injuries$INJURIES),]
injuries <- injuries[order(injuries$INJURIES),]
figure1 <- ggplot(injuries, aes(x = reorder (EVTYPE, INJURIES), y =INJURIES)) +
geom_bar(stat = "identity", fill = "green") +
ggtitle("Events by Injuries") + labs(x="Event", y="Injuries") +
theme(axis.text = element_text(angle = 45,hjust = 1))
figure1
## Processing data
data$PROPDMGMult <- ifelse (data$PROPDMGEXP == "K", 1000, ifelse (data$PROPDMGEXP == "M", 1000000, ifelse (data$PROPDMGEXP == "B", 1000000000, 0)))
data$PROPDMGAMT <- data$PROPDMG*data$PROPDMGMult
data$CROPDMGMult <- ifelse (data$CROPDMGEXP == "K", 1000, ifelse (data$CROPDMGEXP == "M", 1000000, ifelse (data$CROPDMGEXP == "B", 1000000000, 0)))
data$CROPDMGAMT <- data$CROPDMG*data$CROPDMGMult
data$TOTALDMGAMT <- data$PROPDMGAMT+data$CROPDMGAMT
## Damage
damage <- aggregate(TOTALDMGAMT ~ EVTYPE, data= data, FUN = sum)
damage <- damage[damage$TOTALDMGAMT>mean(damage$TOTALDMGAMT),]
damage <- damage[order(damage$TOTALDMGAMT),]
figure2 <- ggplot(damage, aes(x = reorder (EVTYPE, TOTALDMGAMT), y =TOTALDMGAMT)) +
geom_bar(stat = "identity", fill = "blue") +
ggtitle("Events by Damage") + labs(x="Event", y="Damage") +
theme(axis.text = element_text(angle = 45,hjust = 1))
figure2
As can be seen in the figure, tornadoes are clearly the most harmful cause for the health of the population of the United States.
On the other hand, the following events are far removed from tornadoes, without reaching a third of them together.
Although tornadoes are the most harmful event for the health of U.S. citizens, they do not correspond to economic losses. The four events that have the most economic consequences are in order: Flood, Hurricane/Typhoon, Tornado and Storm surge. It is observed that floods entail twice as much economic losses as hurricanes.
The rest of the events outside the top four are much smaller.