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.
This report consists in analyzing the NOAA storm database containing data on extreme climate events. This data was collected during the period from 1950 through 2011. The purpose of this analysis is to answer the following two questions:
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.6.1
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.6.1
if(!file.exists("/StormData.csv.bz2")){
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2",destfile="./StormData.csv.bz2")
}
stormData <- read.csv("repdata_data_StormData.csv")
read in data subset data to only relevant variables (7 in total) convert PROPDMG and CROPDMG from units to numbers () omit variables PROPDMGEXP and CROPDMGEXP restructure data to have tidy dataset with only 3 variables ###Select the variables needed for this analysis
storm_Datasort <- stormData[, c(8, 23:28)]
head(storm_Datasort)
## EVTYPE FATALITIES INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP
## 1 TORNADO 0 15 25.0 K 0
## 2 TORNADO 0 0 2.5 K 0
## 3 TORNADO 0 2 25.0 K 0
## 4 TORNADO 0 2 2.5 K 0
## 5 TORNADO 0 2 2.5 K 0
## 6 TORNADO 0 6 2.5 K 0
summary(storm_Datasort$FATALITIES)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.0000 0.0000 0.0168 0.0000 583.0000
summary(storm_Datasort$INJURIES)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.0000 0.0000 0.1557 0.0000 1700.0000
total_injuries <- storm_Datasort%>%
group_by(EVTYPE)%>%
summarise(INJURIES = sum(INJURIES))%>%
arrange(desc(INJURIES))%>%
top_n(10)
## Selecting by INJURIES
total_FATALITIES <- storm_Datasort%>%
group_by(EVTYPE)%>%
summarise(FATALITIES = sum(FATALITIES))%>%
arrange(desc(FATALITIES))%>%
top_n(10)
## Selecting by FATALITIES
par(mfrow=c(1,2), mar = c(10,3,3,2))
barplot(total_FATALITIES$FATALITIES, names.arg = total_FATALITIES$EVTYPE, las = 2, col = "blue", ylab="Fatalities", main = "Top 10 fatalities")
barplot(total_injuries$INJURIES, names.arg = total_injuries$EVTYPE, las = 2, col = "red", ylab="Injuries", main = "Top 10 Injuries")
stormData$PROPDAMAGE = 0
stormData[stormData$PROPDMGEXP == "H", ]$PROPDAMAGE = stormData[stormData$PROPDMGEXP == "H", ]$PROPDMG * 10^2
stormData[stormData$PROPDMGEXP == "K", ]$PROPDAMAGE = stormData[stormData$PROPDMGEXP == "K", ]$PROPDMG * 10^3
stormData[stormData$PROPDMGEXP == "M", ]$PROPDAMAGE = stormData[stormData$PROPDMGEXP == "M", ]$PROPDMG * 10^6
stormData[stormData$PROPDMGEXP == "B", ]$PROPDAMAGE = stormData[stormData$PROPDMGEXP == "B", ]$PROPDMG * 10^9
stormData$CROPDAMAGE = 0
stormData[stormData$CROPDMGEXP == "H", ]$CROPDAMAGE = stormData[stormData$CROPDMGEXP == "H", ]$CROPDMG * 10^2
stormData[stormData$CROPDMGEXP == "K", ]$CROPDAMAGE = stormData[stormData$CROPDMGEXP == "K", ]$CROPDMG * 10^3
stormData[stormData$CROPDMGEXP == "M", ]$CROPDAMAGE = stormData[stormData$CROPDMGEXP == "M", ]$CROPDMG * 10^6
stormData[stormData$CROPDMGEXP == "B", ]$CROPDAMAGE = stormData[stormData$CROPDMGEXP == "B", ]$CROPDMG * 10^9
economicDamage <- aggregate(PROPDAMAGE + CROPDAMAGE ~ EVTYPE, stormData, sum)
names(economicDamage) <- c("EVENT_TYPE", "TOTAL_DAMAGE")
economicDamage <- arrange(economicDamage, desc(TOTAL_DAMAGE)) %>%
top_n(20)
## Selecting by TOTAL_DAMAGE
economicDamage$TOTAL_DAMAGE <- economicDamage$TOTAL_DAMAGE/10^9
economicDamage$EVENT_TYPE <- factor(economicDamage$EVENT_TYPE, levels = economicDamage$EVENT_TYPE)
head(economicDamage)
## EVENT_TYPE TOTAL_DAMAGE
## 1 FLOOD 150.31968
## 2 HURRICANE/TYPHOON 71.91371
## 3 TORNADO 57.34061
## 4 STORM SURGE 43.32354
## 5 HAIL 18.75290
## 6 FLASH FLOOD 17.56213
par(mfrow=c(1,1), mar = c(10,3,3,2))
barplot(economicDamage$TOTAL_DAMAGE, names.arg = economicDamage$EVENT_TYPE,
las = 2, col = "yellow", ylab="Total Damage", main = "Total Property and Crop damage by 20 Event types")
Main conclusions of the study are as follows: 1. Tornado is the most hazordous climate event with more than 5600 deaths and 91400 injuries. 2. Floods have caused the most significant economic damage - more than 157 billion USD.