SYNOPSIS:

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 project has analyzed the NOAA storm database across United States to find out which types of events are most harmful with respect to population health and which types of events have the greatest economic consequences.Though there can be the multiple factors for answering the harmfulness to population health and economy but in this study no of fatalities caused and damage to property & crops have been considered the major factors.

Data Processing:

##read in the NOAA Data
library(knitr)
library(plyr)
## Warning: package 'plyr' was built under R version 4.0.2
library(data.table)
## Warning: package 'data.table' was built under R version 4.0.2
library(ggplot2)
library(lattice)
NOAAdata <- read.csv("repdata_data_StormData.csv", sep=",", header=TRUE)

## Data subsetting to answer the questions of the assignment

tidyNOAA <- NOAAdata[,c('EVTYPE','FATALITIES','INJURIES', 'PROPDMG', 'PROPDMGEXP', 'CROPDMG', 'CROPDMGEXP')]


##Plot out the results of the fatalities for each evtype
fatalities <- aggregate(FATALITIES ~ EVTYPE, data=tidyNOAA, sum)
fatalities <- arrange(fatalities,desc(FATALITIES),EVTYPE)[1:10,]
fatalities$EVTYPE <- factor(fatalities$EVTYPE, levels = fatalities$EVTYPE)

fatalitiesbyweather <- ggplot(fatalities, aes(x = EVTYPE, y = FATALITIES)) + 
    geom_bar(stat = "identity", fill = "blue", width = NULL) + 
    theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
    xlab("Event Type") + ylab("Fatalities") + ggtitle("Number of fatalities by top 10 Weather Events")
plot(fatalitiesbyweather)

##Have to get the real values for the property and crop damages, these are saved with an indicator of (H,T,M,B) into new columns for each property and crop (10^2, 10^3, 10^6, 10^9) times the damage to get the actual amount

##property damamge
tidyNOAA$PROPDMGNUM = 0
tidyNOAA[tidyNOAA$PROPDMGEXP == "H", ]$PROPDMGNUM = tidyNOAA[tidyNOAA$PROPDMGEXP == "H", ]$PROPDMG * 10^2
tidyNOAA[tidyNOAA$PROPDMGEXP == "K", ]$PROPDMGNUM = tidyNOAA[tidyNOAA$PROPDMGEXP == "K", ]$PROPDMG * 10^3
tidyNOAA[tidyNOAA$PROPDMGEXP == "M", ]$PROPDMGNUM = tidyNOAA[tidyNOAA$PROPDMGEXP == "M", ]$PROPDMG * 10^6
tidyNOAA[tidyNOAA$PROPDMGEXP == "B", ]$PROPDMGNUM = tidyNOAA[tidyNOAA$PROPDMGEXP == "B", ]$PROPDMG * 10^9
## crop damage
tidyNOAA$CROPDMGNUM = 0
tidyNOAA[tidyNOAA$CROPDMGEXP == "H", ]$CROPDMGNUM = tidyNOAA[tidyNOAA$CROPDMGEXP == "H", ]$CROPDMG * 10^2
tidyNOAA[tidyNOAA$CROPDMGEXP == "K", ]$CROPDMGNUM = tidyNOAA[tidyNOAA$CROPDMGEXP == "K", ]$CROPDMG * 10^3
tidyNOAA[tidyNOAA$CROPDMGEXP == "M", ]$CROPDMGNUM = tidyNOAA[tidyNOAA$CROPDMGEXP == "M", ]$CROPDMG * 10^6
tidyNOAA[tidyNOAA$CROPDMGEXP == "B", ]$CROPDMGNUM = tidyNOAA[tidyNOAA$CROPDMGEXP == "B", ]$CROPDMG * 10^9

##Agregate the crop and property damages by evtype and then reorder to have highest number of damage at the top and display top 10

croppropdamage <- aggregate(PROPDMGNUM+CROPDMGNUM ~ EVTYPE, data=tidyNOAA, sum)
names(croppropdamage) = c("EVTYPE", "TOTALDAMAGE")
croppropdamage <- arrange(croppropdamage,desc(croppropdamage$TOTALDAMAGE),EVTYPE)[1:10,]
croppropdamage$EVTYPE <- factor(croppropdamage$EVTYPE, levels = croppropdamage$EVTYPE)

##plot the total damages by evtype
procropdamage <- ggplot(croppropdamage, aes(x = EVTYPE, y = TOTALDAMAGE)) + 
    geom_bar(stat = "identity", fill = "blue") + 
    theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 
    xlab("Event Type") + ylab("Damages ($)") + ggtitle("Property & Crop Damages by top 10 Weather Events")

plot(procropdamage)

RESULTS:

  1. Tornados have caused high fatalities, so they are most harmful for population health.
  2. Floods have caused comparatively huge damage to properties and crops, so they have high economic consequences.