Executive Summary

A database of weather events recorded in USA from 1/03/1950 to 11/30/2011 is used to respond to two questions, regarding population health and economic impact due to these weather events. The database is read and stored as a data frame, in a quick review it is noted that the data needs to be processed in order to get accurate numbers due to errors on event type names, and the order of magnitude for economic variables. Data was processed and analyze to show by means of descending order tables, the impact of event types on population health and economic impact. Further work is explained on the conclusions.

Introduction

The goal of the present project is to analyze the database from NOAA Satellite and Information National Climate Data Center, in order to respond 2 basic questions:

  1. Across the United States, which types of events are most harmful with respect to population health?

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

The data used in the project is was obtained from https://www.ncdc.noaa.gov website.

Data Processing

Installing all packages and libraries required to execute code.

#library(dplyr)
library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.2     ✓ dplyr   1.0.2
## ✓ tidyr   1.1.1     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## ── Conflicts ──────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()

Data is provided by NOAA Satellite and Information Service from National Climate Data Center, U.S. Department of Commerce. The database used for this project can be found at https://www.ncdc.noaa.gov/stormevents/ and is dated August 17, 2007.

First step is to get the database read, the file is written as CSV, the output is stored as a data frame named data_weather.

data_weather <- read.csv("repdata-data-StormData.csv.bz2", header = TRUE, sep = ",")

By making a quick review on this database, we can find the number and name of variables, number of observations and variable classes.

str(data_weather)
## 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : chr  "4/18/1950 0:00:00" "4/18/1950 0:00:00" "2/20/1951 0:00:00" "6/8/1951 0:00:00" ...
##  $ BGN_TIME  : chr  "0130" "0145" "1600" "0900" ...
##  $ TIME_ZONE : chr  "CST" "CST" "CST" "CST" ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: chr  "MOBILE" "BALDWIN" "FAYETTE" "MADISON" ...
##  $ STATE     : chr  "AL" "AL" "AL" "AL" ...
##  $ EVTYPE    : chr  "TORNADO" "TORNADO" "TORNADO" "TORNADO" ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : chr  "" "" "" "" ...
##  $ BGN_LOCATI: chr  "" "" "" "" ...
##  $ END_DATE  : chr  "" "" "" "" ...
##  $ END_TIME  : chr  "" "" "" "" ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : chr  "" "" "" "" ...
##  $ END_LOCATI: chr  "" "" "" "" ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: chr  "K" "K" "K" "K" ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: chr  "" "" "" "" ...
##  $ WFO       : chr  "" "" "" "" ...
##  $ STATEOFFIC: chr  "" "" "" "" ...
##  $ ZONENAMES : chr  "" "" "" "" ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : chr  "" "" "" "" ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...
data_weather$EVTYPE <- toupper(data_weather$EVTYPE)

There are 37 variables registered in all 902,297 observations, in the document named STORM DATA PREPARATION by NOAA, there is a description of all these variables, and the event types. Based on the data description in the document our interest will be on the following variables:

  1. Population health impact: FATALITIES and INJURIES.

  2. Economic consequences: property damage PROPDMG and crop damage CROPDMG.

FATALITIES, INJURIES, PROPDMG and CROPDMG are all numeric variables so there is no need to process them for doing arithmetic operations.

Another important note is to verify which is the period of data recording, to determine this, we can use the variables BGN_DATE which is the starting date of the event, and END_DATE for the last date of the event:

Start date:

min(as.Date(data_weather$BGN_DATE, format = "%m/%d/%Y %H:%M:%S"))
## [1] "1950-01-03"

End date:

max(as.Date(data_weather$BGN_DATE, format = "%m/%d/%Y %H:%M:%S"))
## [1] "2011-11-30"

Also, we want to know which events are the top contributors for these variables, in document STORM DATA PREPARATION it is listed 48 different event types. In the following code, there is an extraction of all the different values in the the variable EVTYPE (used to name the event type).

length(unique(data_weather$EVTYPE))
## [1] 898

We can notice there are 898 different event type names in the database, a quick look at this vector of event types, some events are recorded with acronyms, larger descriptions and even typos. In addition, some rows are summaries for a given time lapse, so these rows need to be ignored.

Since our interest is on the variables regarding population health impact (FATALITIES, INJURIES) and economic consequences (PROPDMG, CROPDMG), we have to look at the event types of highest contribution towards these variables, and see if we are not missing relevant information.

To determine economic consequences due by event, we need to account for both crop and property damage. Both variables report a numeric value per event, and the order of this value is on these variables: CROPDMGEXP and PROPDMGEXP.

Here is the conversion of the order of the variable to a numeric value in USD:

x <- rep(1, length(data_weather$PROPDMGEXP))
x[which(data_weather$PROPDMGEXP == "K")] <- 1000
x[which(data_weather$PROPDMGEXP == "M")] <- 1000000
x[which(data_weather$PROPDMGEXP == "B")] <- 1000000000

data_weather$PROPDMGEXP <- x

x <- rep(1, length(data_weather$CROPDMGEXP))
x[which(data_weather$CROPDMGEXP == "K")] <- 1000
x[which(data_weather$CROPDMGEXP == "M")] <- 1000000
x[which(data_weather$CROPDMGEXP == "B")] <- 1000000000

data_weather$CROPDMGEXP <- x

Now, our data frame data_weather is ready to answer our questions.

Results

Most harmful events on respect to human health

Let’s see the top contributors on health impact, to do this, we will add the count of FATALITIES and INJURIES for event type, stored in a new variable called HEALTH. Then calculate the cumulative by event type, print a table for the top 25 contributors and analyze the data.

data_health <- mutate(data_weather, HEALTH = FATALITIES + INJURIES)
top_health <- enframe(with(data_health, tapply(HEALTH, EVTYPE, sum)))
names(top_health) <- c("EVTYPE","HEALTH")
top_health <- top_health[order(top_health$HEALTH, decreasing = TRUE),]
top_health$cumulative <- cumsum(top_health$HEALTH)
top_health$share <- 100*top_health$HEALTH/sum(top_health$HEALTH)
top_health$EVTYPE <- factor(top_health$EVTYPE, levels = top_health$EVTYPE)
top_health$percentage <- 100*top_health$cumulative/sum(top_health$HEALTH)

Here is a table with the information:

df_toprint <- top_health[1:25,]
print.data.frame(df_toprint, digits =3)
##                EVTYPE HEALTH cumulative  share percentage
## 1             TORNADO  96979      96979 62.297       62.3
## 2      EXCESSIVE HEAT   8428     105407  5.414       67.7
## 3           TSTM WIND   7461     112868  4.793       72.5
## 4               FLOOD   7259     120127  4.663       77.2
## 5           LIGHTNING   6046     126173  3.884       81.1
## 6                HEAT   3037     129210  1.951       83.0
## 7         FLASH FLOOD   2755     131965  1.770       84.8
## 8           ICE STORM   2064     134029  1.326       86.1
## 9   THUNDERSTORM WIND   1621     135650  1.041       87.1
## 10       WINTER STORM   1527     137177  0.981       88.1
## 11          HIGH WIND   1385     138562  0.890       89.0
## 12               HAIL   1376     139938  0.884       89.9
## 13  HURRICANE/TYPHOON   1339     141277  0.860       90.8
## 14         HEAVY SNOW   1148     142425  0.737       91.5
## 15           WILDFIRE    986     143411  0.633       92.1
## 16 THUNDERSTORM WINDS    972     144383  0.624       92.7
## 17           BLIZZARD    906     145289  0.582       93.3
## 18                FOG    796     146085  0.511       93.8
## 19        RIP CURRENT    600     146685  0.385       94.2
## 20   WILD/FOREST FIRE    557     147242  0.358       94.6
## 21          HEAT WAVE    551     147793  0.354       94.9
## 22       RIP CURRENTS    501     148294  0.322       95.3
## 23         DUST STORM    462     148756  0.297       95.6
## 24     WINTER WEATHER    431     149187  0.277       95.8
## 25     TROPICAL STORM    398     149585  0.256       96.1

Now it is clear which events are the top contributors for health impact, notice that the top 21 account for 95% of total, moreover, TORNADO is top on table with just above 62% share, with EXCESSIVE HEAT and THUNDERSTORM follow with we will focus on these events. Also, in this top 25 list there are some events named in different ways, such as THUNDERSTORM or TSTM, in order to have a more accurate numbers, let’s correct the typos and set event type THUNDERSTORM and TORNADO to the one used in the STORM DATA PREPARATION file.

# taken from the original database
list_TSTM <- grep("TSTM|THUNDERSTORM", data_weather$EVTYPE)
data_weather$EVTYPE[list_TSTM] <- "THUNDERSTORM"
list_TORNADO <- grep("TORNADO", data_weather$EVTYPE)
data_weather$EVTYPE[list_TORNADO] <- "TORNADO"

Now most of the events with highest impact towards human health has been stored with the name used in the data description file. So we can answer the question number 1, with an better accuracy:

Across the United States, which types of events are most harmful with respect to population health?

Let’s repeat the process to consolidate the information within a table:

data_health <- mutate(data_weather, HEALTH = FATALITIES + INJURIES)
top_health <- enframe(with(data_health, tapply(HEALTH, EVTYPE, sum)))
names(top_health) <- c("EVTYPE","HEALTH")
top_health <- top_health[order(top_health$HEALTH, decreasing = TRUE),]
top_health$cumulative <- cumsum(top_health$HEALTH)
top_health$share <- 100*top_health$HEALTH/sum(top_health$HEALTH)
top_health$EVTYPE <- factor(top_health$EVTYPE, levels = top_health$EVTYPE)
top_health$percentage <- 100*top_health$cumulative/sum(top_health$HEALTH)
df_toprint <- top_health[1:25,]
print.data.frame(df_toprint, digits =3)
##               EVTYPE HEALTH cumulative  share percentage
## 1            TORNADO  97043      97043 62.338       62.3
## 2       THUNDERSTORM  10298     107341  6.615       69.0
## 3     EXCESSIVE HEAT   8428     115769  5.414       74.4
## 4              FLOOD   7259     123028  4.663       79.0
## 5          LIGHTNING   6046     129074  3.884       82.9
## 6               HEAT   3037     132111  1.951       84.9
## 7        FLASH FLOOD   2755     134866  1.770       86.6
## 8          ICE STORM   2064     136930  1.326       88.0
## 9       WINTER STORM   1527     138457  0.981       88.9
## 10         HIGH WIND   1385     139842  0.890       89.8
## 11              HAIL   1376     141218  0.884       90.7
## 12 HURRICANE/TYPHOON   1339     142557  0.860       91.6
## 13        HEAVY SNOW   1148     143705  0.737       92.3
## 14          WILDFIRE    986     144691  0.633       92.9
## 15          BLIZZARD    906     145597  0.582       93.5
## 16               FOG    796     146393  0.511       94.0
## 17       RIP CURRENT    600     146993  0.385       94.4
## 18  WILD/FOREST FIRE    557     147550  0.358       94.8
## 19         HEAT WAVE    551     148101  0.354       95.1
## 20      RIP CURRENTS    501     148602  0.322       95.5
## 21        DUST STORM    462     149064  0.297       95.8
## 22    WINTER WEATHER    431     149495  0.277       96.0
## 23    TROPICAL STORM    398     149893  0.256       96.3
## 24         AVALANCHE    394     150287  0.253       96.5
## 25      EXTREME COLD    393     150680  0.252       96.8
p <- ggplot(data = top_health, aes())

The next charts shows population impact by weather event:

p <- ggplot(top_health[1:20,], aes(x=EVTYPE,y=HEALTH)) + geom_bar(stat="identity")
p <- p + theme(axis.text.x = element_text(angle = 90))
p <- p + labs(title="Population health impact by weather event type", x=NULL, y="FATALITIES + INJURIES")
p

It is clear that TORNADOS are the weather events that caused most harmful with population health, followed by THUNDERSTORM and EXCESSIVE HEAT. TORNADOS account for just over 62% of both fatalities and injuries numbers, while THUNDERSORM represents just about 6%. Although in this analysis it was considered up to 95% of the data due to typos and misleading names for event types, there is enough information to assume no changes on the top may occur if all the data is taken into account.

Greatest economic consequences

To respond the second question, we need to add both PROPDMG and CROPDMG variables, after convert them on the same units for every event. Within the next code, both variables are added in USD then grouped by event type stored in a variable called ECONIMPACT, finally it is converted into millions USD.

data_weather$ECONIMPACT <- with(data_weather,PROPDMGEXP*PROPDMG + CROPDMGEXP*CROPDMG)
top_economic <- enframe(with(data_weather, tapply(ECONIMPACT,EVTYPE,sum)))
names(top_economic) <- c("EVTYPE","ECONIMPACT")
top_economic$ECONIMPACT <- top_economic$ECONIMPACT/1000000
top_economic <- top_economic[order(top_economic$ECONIMPACT, decreasing = TRUE),]
top_economic$cumulative <- cumsum(top_economic$ECONIMPACT)
top_economic$share <- 100*top_economic$ECONIMPACT/sum(top_economic$ECONIMPACT)
top_economic$EVTYPE <- factor(top_economic$EVTYPE, levels = top_economic$EVTYPE)
top_economic$percentage <- 100*top_economic$cumulative/sum(top_economic$ECONIMPACT)

Results are reported in the following table:

df_toprint <- top_economic[1:25,]
print.data.frame(df_toprint, digits =3)
##                       EVTYPE ECONIMPACT cumulative  share percentage
## 1                      FLOOD     150320     150320 31.555       31.6
## 2          HURRICANE/TYPHOON      71914     222233 15.096       46.7
## 3                    TORNADO      57397     279630 12.049       58.7
## 4                STORM SURGE      43324     322953  9.094       67.8
## 5                       HAIL      18753     341706  3.937       71.7
## 6                FLASH FLOOD      17562     359269  3.687       75.4
## 7                    DROUGHT      15019     374287  3.153       78.6
## 8                  HURRICANE      14610     388897  3.067       81.6
## 9               THUNDERSTORM      13848     402745  2.907       84.5
## 10               RIVER FLOOD      10148     412894  2.130       86.7
## 11                 ICE STORM       8967     421861  1.882       88.6
## 12            TROPICAL STORM       8382     430243  1.760       90.3
## 13              WINTER STORM       6715     436958  1.410       91.7
## 14                 HIGH WIND       5909     442867  1.240       93.0
## 15                  WILDFIRE       5061     447928  1.062       94.0
## 16          STORM SURGE/TIDE       4642     452570  0.974       95.0
## 17            HURRICANE OPAL       3162     455731  0.664       95.7
## 18          WILD/FOREST FIRE       3109     458840  0.653       96.3
## 19 HEAVY RAIN/SEVERE WEATHER       2500     461340  0.525       96.8
## 20                HEAVY RAIN       1428     462768  0.300       97.1
## 21              EXTREME COLD       1381     464148  0.290       97.4
## 22              FROST/FREEZE       1105     465253  0.232       97.7
## 23                HEAVY SNOW       1067     466320  0.224       97.9
## 24                 LIGHTNING        941     467261  0.197       98.1
## 25                  BLIZZARD        771     468032  0.162       98.2

Bar chart with economic impact by weather event:

p <- ggplot(top_economic[1:20,], aes(x=EVTYPE,y=ECONIMPACT)) + geom_bar(stat="identity")
p <- p + theme(axis.text.x = element_text(angle = 90))
p <- p + labs(title="Economic consequences by weather event type", x=NULL, y="CROP AND PROPERTY DAMAGE (MUSD)")
p

The table and chart shown FLOOD is the weather event that causes the most economic impact a total of 150.3 billion USD accounts for 31.6% of total economic impact, while the second event with most impact is HURRICANE/TYPHOON with just over 15% of the total. In this case, the difference between the 2 top event types is closer than the health case, just 15%, but enough to assume the data considered gave us an accurate answer.

Conclusions

According to the data reported by NAOO Satellite and Information Service, Tornado and Flood are the most impacting climate events for human health and economic consequences respectively. The database has some inconsistencies on the event types recorded, which leads to a quick review and transformation of the data in order to achieve a good level of confidence on the analysis. If a more accurate analysis should be perform, it is required to do a further work on the variable for event type so to have just the events considered on the data description file to account for every single data.