The following project analyzes the U.S. National Oceanic and Atmospheric Administration’s storm database to find which weather events are most harmful with respect to population health and which events have the greatest economic impact. 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. The database was read and the event types and its effect on population and properties was analysed using R code.
Load the required libraries
library(dplyr)
Load the data from the url provided.
fileUrl <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(fileUrl,dest="Strom_Data.bz2")
Read the bz2 file into R
stormdata <- read.csv("Strom_Data.bz2")
Sum up the Fatalities and Injuries into a single column to calculate the effect of events on population
stormdata$POP_EFFECT <- stormdata$FATALITIES + stormdata$INJURIES
Pick up the required columns into a new dataframe and aggregate by events and pick up the top 10 to plot
library(dplyr)
df <- stormdata[,c("EVTYPE","POP_EFFECT" )]
df1 <- df %>% group_by(EVTYPE) %>% summarise(tot = sum(POP_EFFECT)) %>% arrange(desc(tot)) %>% as.data.frame()
pop_effect <- df1[1:10,]
Plot the results to show the analysis
par(mar=c(8,6,2,2))
barplot(pop_effect$tot, names.arg = pop_effect[1:10,1],
las = 2, cex.names = 0.7, xlab = " ", ylab = " ",
main = "Effects on Population by Event Type (Top 10)")
mtext("Events Causing Casualities", side = 1, line = 5.5)
mtext("Total Fatalities & Injuries", side = 2, line = 4)
Among weather related events in the U.S., tornados had the greatest health impact, causing fatalities & injures of over 90,000.
Calculate property damage and Crop Damage
library(dplyr)
##
## 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
stormdata <- mutate(stormdata, Property_Damage = if_else(PROPDMGEXP=="K", PROPDMG*10^3,
if_else(PROPDMGEXP=="M", PROPDMG*10^6,
if_else(PROPDMGEXP=="B", PROPDMG*10^9, PROPDMG))))
stormdata <- mutate(stormdata, Crop_Damage = if_else(CROPDMGEXP=="K", CROPDMG*10^3,
if_else(CROPDMGEXP=="M", CROPDMG*10^6,
if_else(CROPDMGEXP=="B", CROPDMG*10^9, CROPDMG))))
Sum and aggregate up the property damanges into a single column
stormdata <- mutate(stormdata, Total_Damage = Property_Damage + Crop_Damage)
TotalDamage <- stormdata %>%
group_by(EVTYPE) %>%
summarize(Total_Damage=sum(Total_Damage)/10^9) %>%
arrange(desc(Total_Damage)) %>%
as.data.frame()
Plot the Property & Crop Damage
par(mar=c(8,6,2,2))
barplot(TotalDamage[1:10,2], names.arg = TotalDamage[1:10,1],
las = 2, cex.names = 0.7, xlab = "", ylab = "",
main = "Total Property & Crop Damage by Event Type in the U.S. (Top 10)")
mtext("Event Type", side = 1, line = 5.5)
mtext("Property & Crop Damage (Billions)", side = 2, line = 4)
Among weather related events in the U.S., flooding has the greatest economic consequences, causing property & crop damage of over $150 Billion.