knitr::opts_chunk$set(echo = TRUE)

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.

Data Processing

noaaDF <- read.csv("repdata-data-StormData.csv.bz2", header = TRUE, stringsAsFactors = FALSE)

Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?

totalFatalities <- aggregate(noaaDF$FATALITIES, by = list(noaaDF$EVTYPE), sum)
names(totalFatalities) <- c("Event", "Fatalities")
totalFatalitiesOrdered <- totalFatalities[order(-totalFatalities$Fatalities), ][1:10, ]
totalFatalitiesOrdered
##              Event Fatalities
## 834        TORNADO       5633
## 130 EXCESSIVE HEAT       1903
## 153    FLASH FLOOD        978
## 275           HEAT        937
## 464      LIGHTNING        816
## 856      TSTM WIND        504
## 170          FLOOD        470
## 585    RIP CURRENT        368
## 359      HIGH WIND        248
## 19       AVALANCHE        224
totalInjuries <- aggregate(noaaDF$INJURIES, by = list(noaaDF$EVTYPE), sum)
names(totalInjuries) <- c("Event", "Injuries")
totalInjuriesOrdered <- totalInjuries[order(-totalInjuries$Injuries), ][1:10, ]
totalInjuriesOrdered
##                 Event Injuries
## 834           TORNADO    91346
## 856         TSTM WIND     6957
## 170             FLOOD     6789
## 130    EXCESSIVE HEAT     6525
## 464         LIGHTNING     5230
## 275              HEAT     2100
## 427         ICE STORM     1975
## 153       FLASH FLOOD     1777
## 760 THUNDERSTORM WIND     1488
## 244              HAIL     1361

Across the United States, which types of events have the greatest economic consequences?

totalPropertyDamage <- aggregate(noaaDF$PROPDMG, by = list(noaaDF$EVTYPE), "sum")
names(totalPropertyDamage) <- c("Event", "Property")
totalPropertyDamageOrdered <- totalPropertyDamage[order(-totalPropertyDamage$Property), ][1:10, ]
totalPropertyDamageOrdered
##                  Event  Property
## 834            TORNADO 3212258.2
## 153        FLASH FLOOD 1420124.6
## 856          TSTM WIND 1335965.6
## 170              FLOOD  899938.5
## 760  THUNDERSTORM WIND  876844.2
## 244               HAIL  688693.4
## 464          LIGHTNING  603351.8
## 786 THUNDERSTORM WINDS  446293.2
## 359          HIGH WIND  324731.6
## 972       WINTER STORM  132720.6
totalCropDamage <- aggregate(noaaDF$CROPDMG, by = list(noaaDF$EVTYPE), sum)
names(totalCropDamage) <- c("Event", "Crop")
totalCropDamageOrdered <- totalCropDamage[order(-totalCropDamage$Crop), ][1:20, ]
totalCropDamageOrdered
##                  Event      Crop
## 244               HAIL 579596.28
## 153        FLASH FLOOD 179200.46
## 170              FLOOD 168037.88
## 856          TSTM WIND 109202.60
## 834            TORNADO 100018.52
## 760  THUNDERSTORM WIND  66791.45
## 95             DROUGHT  33898.62
## 786 THUNDERSTORM WINDS  18684.93
## 359          HIGH WIND  17283.21
## 290         HEAVY RAIN  11122.80
## 212       FROST/FREEZE   7034.14
## 140       EXTREME COLD   6121.14
## 848     TROPICAL STORM   5899.12
## 402          HURRICANE   5339.31
## 164     FLASH FLOODING   5126.05
## 411  HURRICANE/TYPHOON   4798.48
## 957           WILDFIRE   4364.20
## 873     TSTM WIND/HAIL   4356.65
## 955   WILD/FOREST FIRE   4189.54
## 464          LIGHTNING   3580.61
TotalCost <- aggregate(noaaDF$CROPDMG+noaaDF$PROPDMG, by = list(noaaDF$EVTYPE), sum)
names(TotalCost) <- c("Event", "TotalCost")
TotalCostOrdered <- TotalCost[order(-TotalCost$TotalCost), ][1:10, ]
TotalCostOrdered
##                  Event TotalCost
## 834            TORNADO 3312276.7
## 153        FLASH FLOOD 1599325.1
## 856          TSTM WIND 1445168.2
## 244               HAIL 1268289.7
## 170              FLOOD 1067976.4
## 760  THUNDERSTORM WIND  943635.6
## 464          LIGHTNING  606932.4
## 786 THUNDERSTORM WINDS  464978.1
## 359          HIGH WIND  342014.8
## 972       WINTER STORM  134699.6

Including Plots

Results Graphically represent the number of fatalities and injuries by the 10 most harmful weather events to visualise the results.

You can also embed plots, for example:

library(ggplot2)
library(gridExtra)
library(scales)

plotFatalities <- ggplot(totalFatalitiesOrdered, aes(Event, Fatalities)) + geom_col() + ggtitle("Top 10 Deadly Weather Events") + labs(x = "Weather Event", y = "Number of Fatalities") + theme(axis.text.x = element_text(angle = 90, size = 5))

plotInjuries <- ggplot(totalInjuriesOrdered, aes(Event, Injuries)) + geom_col() + ggtitle("Top 10 Weather Events by Injury") + labs(x = "Weather Event", y = "Number of Injuries") + theme(axis.text.x = element_text(angle = 90, size = 5))

grid.arrange(plotFatalities, plotInjuries, nrow = 2)

Summary: It is strikingly clear that a torando is the most severe weather event in reference to population health. While excessive heat causes a substantial number of fatalities, it is on par with floods, lightning and tstm wind in terms of injuries.

Graphically represent the property damage, crop damage and total economic damage by the top 10 weather events to visualise the results.

library(ggplot2)
library(gridExtra)
library(scales)

plotProperty <- ggplot(totalPropertyDamageOrdered, aes(Event, Property)) + geom_col() + ggtitle("Top 10 Weather Events by Property Damage") + labs(x = "Weather Event", y = "Property Damage") + theme(axis.text.x = element_text(angle = 90, size = 5)) + scale_y_continuous(labels = comma)

plotCrop <- ggplot(totalCropDamageOrdered, aes(Event, Crop)) + geom_col() + ggtitle("Top 10 Weather Events by Crop Damage") + labs(x = "Weather Event", y = "Crop Damage") + theme(axis.text.x = element_text(angle = 90, size = 5)) + scale_y_continuous(labels = comma)

grid.arrange(plotProperty, plotCrop, nrow = 2)

plotTotalCost <- ggplot(TotalCostOrdered, aes(Event, TotalCost)) + geom_col() + ggtitle("Top 10 Weather Events by Total Damage") + labs(x = "Weather Event", y = "Total Damage") + theme(axis.text.x = element_text(angle = 90, size = 5)) + scale_y_continuous(labels = comma)
plotTotalCost