Ingroduction

This report is written for the Data Science Course of Coursera in the coursetrack of Course 5, Reproducible Research.In this report, we explore the NOAA Storm Database and analyse the effect of extreme weather effects in the United States.

The report answers 2 questions: 1. Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?

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

Data processing

We first start importing necessary libraries and the Storm data. Then we identify variables in the storm data.

The data is downloaded from the Coursera project website.

library(knitr)
library(ggplot2)
library(dplyr)

data <- read.csv("repdata_data_StormData.csv")

Then we take a look at the available variables in the dataset.

head(data)
##   STATE__           BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE  EVTYPE
## 1       1  4/18/1950 0:00:00     0130       CST     97     MOBILE    AL TORNADO
## 2       1  4/18/1950 0:00:00     0145       CST      3    BALDWIN    AL TORNADO
## 3       1  2/20/1951 0:00:00     1600       CST     57    FAYETTE    AL TORNADO
## 4       1   6/8/1951 0:00:00     0900       CST     89    MADISON    AL TORNADO
## 5       1 11/15/1951 0:00:00     1500       CST     43    CULLMAN    AL TORNADO
## 6       1 11/15/1951 0:00:00     2000       CST     77 LAUDERDALE    AL TORNADO
##   BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END COUNTYENDN
## 1         0                                               0         NA
## 2         0                                               0         NA
## 3         0                                               0         NA
## 4         0                                               0         NA
## 5         0                                               0         NA
## 6         0                                               0         NA
##   END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES INJURIES PROPDMG
## 1         0                      14.0   100 3   0          0       15    25.0
## 2         0                       2.0   150 2   0          0        0     2.5
## 3         0                       0.1   123 2   0          0        2    25.0
## 4         0                       0.0   100 2   0          0        2     2.5
## 5         0                       0.0   150 2   0          0        2     2.5
## 6         0                       1.5   177 2   0          0        6     2.5
##   PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES LATITUDE LONGITUDE
## 1          K       0                                         3040      8812
## 2          K       0                                         3042      8755
## 3          K       0                                         3340      8742
## 4          K       0                                         3458      8626
## 5          K       0                                         3412      8642
## 6          K       0                                         3450      8748
##   LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1       3051       8806              1
## 2          0          0              2
## 3          0          0              3
## 4          0          0              4
## 5          0          0              5
## 6          0          0              6

Then we aggregate the data and have a glance at the results before actually visualise the results in nice tables.

fatalities <- aggregate(FATALITIES ~EVTYPE, data = data, sum, na.rm=TRUE)
fatalities <- arrange(fatalities, desc(FATALITIES))
fatalities<- fatalities[1:10,]
fatalities
##            EVTYPE FATALITIES
## 1         TORNADO       5633
## 2  EXCESSIVE HEAT       1903
## 3     FLASH FLOOD        978
## 4            HEAT        937
## 5       LIGHTNING        816
## 6       TSTM WIND        504
## 7           FLOOD        470
## 8     RIP CURRENT        368
## 9       HIGH WIND        248
## 10      AVALANCHE        224
injuries <- aggregate(INJURIES ~EVTYPE, data = data, sum, na.rm=TRUE)
injuries <- arrange(injuries, desc(INJURIES))
injuries <- injuries[1:10,]
injuries
##               EVTYPE INJURIES
## 1            TORNADO    91346
## 2          TSTM WIND     6957
## 3              FLOOD     6789
## 4     EXCESSIVE HEAT     6525
## 5          LIGHTNING     5230
## 6               HEAT     2100
## 7          ICE STORM     1975
## 8        FLASH FLOOD     1777
## 9  THUNDERSTORM WIND     1488
## 10              HAIL     1361
propdmg <- aggregate(PROPDMG~EVTYPE, data = data, sum, na.rm=TRUE)
propdmg <- arrange(propdmg, desc(PROPDMG))
propdmg <- propdmg[1:10,]
propdmg
##                EVTYPE   PROPDMG
## 1             TORNADO 3212258.2
## 2         FLASH FLOOD 1420124.6
## 3           TSTM WIND 1335965.6
## 4               FLOOD  899938.5
## 5   THUNDERSTORM WIND  876844.2
## 6                HAIL  688693.4
## 7           LIGHTNING  603351.8
## 8  THUNDERSTORM WINDS  446293.2
## 9           HIGH WIND  324731.6
## 10       WINTER STORM  132720.6
cropdmg <- aggregate(CROPDMG~EVTYPE, data = data, sum, na.rm=TRUE)
cropdmg <- arrange(cropdmg, desc(CROPDMG))
cropdmg <- cropdmg[1:10,]
cropdmg
##                EVTYPE   CROPDMG
## 1                HAIL 579596.28
## 2         FLASH FLOOD 179200.46
## 3               FLOOD 168037.88
## 4           TSTM WIND 109202.60
## 5             TORNADO 100018.52
## 6   THUNDERSTORM WIND  66791.45
## 7             DROUGHT  33898.62
## 8  THUNDERSTORM WINDS  18684.93
## 9           HIGH WIND  17283.21
## 10         HEAVY RAIN  11122.80

Results

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

We analyse the effect on fatalities and injuries. Tables show Tornados are the most harmful for both fatalities and injuries.

par(mfrow = c(1, 2), mar = c(15, 8, 4, 4), mgp = c(3, 1, 0), cex = 0.7)

barplot(fatalities$FATALITIES, names.arg = fatalities$EVTYPE, las = 3, main = "Weather events with highest number of fatalities", ylab = "number of fatalities", col = "lightblue")

barplot(injuries$INJURIES, names.arg = injuries$EVTYPE, las = 3, main = "Weather events with highest number of injuries", ylab = "number of injuries", col = "lightblue")

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

For this question, we focus on the variables PROPDMG (Propery Damage) and CROPDMG (Crop Damage). Results show Tornados has the highes property damage and Hails have the highest crop damage.

par(mfrow = c(1, 2), mar = c(15, 8, 4, 4), mgp = c(3, 1, 0), cex = 0.7)

barplot(propdmg$PROPDMG, names.arg = propdmg$EVTYPE, las = 3, main = "Weather events and property damage", ylab = "Propert Damage in USD", col = "lightblue")

barplot(cropdmg$CROPDMG, names.arg = cropdmg$EVTYPE, las = 3, main = "Weather events and crop damage", ylab = "Crop Damage in USD", col = "lightblue")