Synopsis

In this report, we are going to analyse the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. The database contains information on severe weather events across all states in the US from 1950 to 2011. We are going to explore the impact on public health by using the information on injuries and fatalities, as well as the economic impact which is going to be measured through property and crops damage.
As all existing event types have been recorded only since 1996, we will solely look at events that happened in 1996 and later. We will also introduce our own mapping of event types because there are hundreds of different event types in the database.
Throughout the years, there have always been some “key” events which have resulted in enormous damage and plenty of injured or dead people. When looking at the economic impact, we will see that crop damage was mainly due to droughts or wildfires whilst property was damaged mainly because of floods or hurricanes. Latter have also been the main causes for injured people, whilst most people died due to hurricanes or heat. This report will show that events related to wind, i.e. hurricanes, tornados, etc., have the biggest impact on both public health and the economy, hence sufficient safety precautions should be in place.

Data Processing

As a first step, the working directory is set and the data is downloaded as a csv.bz2 file. After the download, the data is imported into the variable df_data and the format of the column containing the date is adjusted.

wd <- getwd()
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2",
              file.path(wd, "repdata-data-StormData.csv.bz2"))
df_data <- read.csv("repdata-data-StormData.csv.bz2")
df_data$BGN_DATE <- as.Date(df_data$BGN_DATE, "%m/%d/%Y")

Next, the data is tidied up by removing columns that are not required for the following analysis. Besides that, a column which contains only the year is created and in order to facilitate the event type mapping, all records in the EVTYPE column are converted to uppercase letters. As there are records for all existing event types only since 1996, the events that occured before 1996 are filtered out.

library(dplyr)
df_data_tidy <- select(df_data, "BGN_DATE", "BGN_TIME", "TIME_ZONE", "COUNTY", "COUNTYNAME", 
                       "STATE", "EVTYPE", "FATALITIES", "INJURIES", "PROPDMG","PROPDMGEXP", 
                       "CROPDMG", "CROPDMGEXP", "REMARKS", "REFNUM")
df_data_tidy["yr"] <- format(df_data_tidy$BGN_DATE, "%Y")
df_data_tidy <- filter(df_data_tidy, df_data_tidy$yr >= 1996 )
df_data_tidy$EVTYPE <- toupper(df_data_tidy$EVTYPE)

In the latter analysis, when looking at the results, there were some obvious outliers in the figures. While investigating them, it was noticed that there are duplicates of some records. A duplicate is defined as a record where the figures in every column, except for the REFNUM column, are exactly the same as in at least one other record. There were 8 events identified as duplicates and in order to not double-count their impact, the duplicates are removed. Most likely, there are more duplicate records in the database, but below are the ones with the biggest impact on the following analysis and they were distorting the results and graphs.

dupes <- c("881156", "858913", "858395", "860154", "858394", "859980", "898415", "893301")
df_data_tidy <- filter(df_data_tidy, !df_data_tidy$REFNUM %in% dupes)

Results

Impact on Population Health

To measure the impact on population health, we only filter on events where either people died or were injured. After that, we have a look at the EVTYPE for the remaining events.

library(dplyr)
df_data_ppl_dmg <- filter(df_data_tidy, (FATALITIES > 0) | (INJURIES > 0))
unique(df_data_ppl_dmg$EVTYPE)

There are 125 unique EVTYPEs after filtering. All of these have been reviewed and a mapping has been created for those. The event categories have been split into: Heat/Fire, Flood/Landslide, Sea conditions, Precipitation, Winter and Wind. Specific key words (as shown in the code below) in the EVTYPE column are used to assign the new event_type to an existent EVTYPE. Eventually, the new column is converted to a factor.

df_data_ppl_dmg <- mutate(df_data_ppl_dmg, event_type = case_when(
    grepl("HEAT|FIRE|HYPER|WARM|DROUGHT", EVTYPE) ~ "HEAT/FIRE",
    grepl("FLOOD|TSUNAMI|SURGE|LANDSLIDE|FLD|MUD", EVTYPE)  ~ "FLOOD/LANDSLIDE",
    grepl("MARINE|SURF|SEAS|CURRENT|WATER|SWELL|WAVE|DROWNING", EVTYPE)  ~ "SEA CONDITIONS",
    grepl("RAIN|FOG|LIGHTNING|HAIL|THUNDERSTORM|TSTM|PRECIP|MICROBURST", EVTYPE)  ~ "PRECIPITATION",
    grepl("COLD|CHILL|FREEZ|FROST|GLAZE|SNOW|ICY|ICE|WINTRY|AVALANCHE|BLIZZARD|WINTER|HYPO", EVTYPE)  ~ "WINTER",
    grepl("STORM|HURRICANE|TORNADO|WIND|DUST|TYPHOON|FUNNEL|OTHER", EVTYPE)  ~ "WIND"))

df_data_ppl_dmg$event_type <- as.factor(df_data_ppl_dmg$event_type)

To make sure that every EVTYPE got a mapping, the next code should be 0 when executed.

sum(is.na(df_data_ppl_dmg$event_type))
## [1] 0

If everything has been mapped, the data can be grouped by year and event_type. While grouping, all injuries and fatalities are summed up separately. We also define the colours for our plots later on.

data_grp_ppl_dmg <- df_data_ppl_dmg %>% 
  group_by(yr, event_type) %>% 
  summarise(inj = sum(INJURIES), deaths = sum(FATALITIES))

cols_ppl_dmg <- c("springgreen4", "red", "blue", "black", "purple", "orange")

First, we are plotting the injuries over the years for each event type.

library(ggplot2)
ggplot(data_grp_ppl_dmg, aes(x=yr, y=inj, colour=event_type, group=event_type)) + 
  geom_line() +
  geom_point() +
  ggtitle("Number of Injuries") +
  theme(plot.title = element_text(hjust = 0.5)) +
  xlab("Year") + ylab("") + 
  theme(legend.position="bottom", legend.title = element_blank()) +
  scale_color_manual(values=cols_ppl_dmg)

We see that the Tornados in spring 2011 and the flood in Texas in October 1998 are the events with the biggest impact. But both wind and heat/fire events have always caused a lot of injuries. Luckily, precipitation, sea conditions and winter conditions never caused many injuries. Next, we’ll plot the fatalities.

library(ggplot2)
ggplot(data_grp_ppl_dmg, aes(x=yr, y=deaths, colour=event_type, group=event_type)) + 
  geom_line() +
  geom_point() +
  ggtitle("Number of Deaths") +
  theme(plot.title = element_text(hjust = 0.5)) +
  xlab("Year") + ylab("") + 
  theme(legend.position="bottom", legend.title = element_blank()) +
  scale_color_manual(values=cols_ppl_dmg)

Wind events, mainly the Tornado in 2011, have always caused a lot of deaths. But in the past, especially in 1999 and 2006, lots of deaths were caused by heat. In comparison, the other event type categories never caused many deaths.

Impact on economy

To answer the second question, we’ll look again at our tidy data set df_data_tidy from above and filter for all events where any property or crops damage occured.

df_data_eco <- filter(df_data_tidy, (df_data_tidy$PROPDMG > 0) | (df_data_tidy$CROPDMG > 0))

As the property and crops damage is measured in different units, we need to convert them all to $. To facilitate this calculation, we check which exponents exist for both damages.

table(df_data_eco$CROPDMGEXP)
## 
##           B     K     M 
## 97949     2 94808  1758
table(df_data_eco$PROPDMGEXP)
## 
##             B      K      M 
##   3681     32 183449   7355

For both, there is ““,”K”, “M” and “B”. The following code converts those exponents to the actual dollar figure and saves it in two new column prop_total and crop_total.

df_data_eco <- mutate(df_data_eco, 
                      prop_total = case_when(PROPDMGEXP == "B" ~ PROPDMG*1000000000,
                                             PROPDMGEXP == "M" ~ PROPDMG*1000000,
                                             PROPDMGEXP == "K" ~ PROPDMG*1000,
                                             PROPDMGEXP == "" ~ PROPDMG*1),
                      crop_total = case_when(CROPDMGEXP == "B" ~ CROPDMG*1000000000,
                                             CROPDMGEXP == "M" ~ CROPDMG*1000000,
                                             CROPDMGEXP == "K" ~ CROPDMG*1000,
                                             CROPDMGEXP == "" ~ CROPDMG*1))

As before, we create a mapping for the column EVTYPE. The basis mapping is the same as in the first section of this report, but as there are more EVTYPEs now, the mapping has been extended. The new mapping column is converted to factor again.

df_data_eco <- mutate(df_data_eco, event_type = case_when(
  grepl("HEAT|FIRE|HYPER|WARM|DROUGHT|SMOKE|VOLCANIC", EVTYPE) ~ "HEAT/FIRE",
  grepl("FLOOD|TSUNAMI|SURGE|LANDSLIDE|FLD|MUD|EROSION|DAM|LANDSLUMP|SLIDE", EVTYPE)  ~ "FLOOD/LANDSLIDE",
  grepl("MARINE|SURF|SEAS|CURRENT|WATER|SWELL|WAVE|DROWNING|TIDE|SEICHE", EVTYPE)  ~ "SEA CONDITIONS",
  grepl("RAIN|FOG|LIGHTNING|HAIL|THUNDERSTORM|TSTM|PRECIP|BURST", EVTYPE)  ~ "PRECIPITATION",
  grepl("COLD|CHILL|FREEZ|FROST|GLAZE|SNOW|ICY|ICE|WINTRY|AVALANCHE|BLIZZARD|WINTER|HYPO", EVTYPE)  ~ "WINTER",
  grepl("STORM|HURRICANE|TORNADO|WIND|DUST|TYPHOON|FUNNEL|OTHER|LANDSPOUT|DEPRESSION", EVTYPE)  ~ "WIND"))

df_data_eco$event_type <- as.factor(df_data_eco$event_type)

Here again, we check that everything has been mapped, i.e. the output should be 0.

sum(is.na(df_data_eco$event_type))
## [1] 0

We again group by year and event type and sum up the damage for property and crops in one total damage column, and divide the result by 1,000,000 to get the final figure in $M. We also define the colours for our plots as before.

data_grp_eco <- df_data_eco %>% 
  group_by(yr, event_type) %>% 
  summarise(total_dmg = sum(crop_total)/1000000 + sum(prop_total)/1000000)

cols_eco <- c("springgreen4", "red", "blue", "black", "purple", "orange")

No, we can plot the aggregated damage.

ggplot(data_grp_eco, aes(x=yr, y=total_dmg, colour=event_type, group=event_type)) + 
  geom_line() +
  geom_point() +
  ggtitle("Aggregated Damage on Crops and Property across the US") + 
  theme(plot.title = element_text(hjust = 0.5)) +
  xlab("Year") + ylab("Damage (in $M)") + 
  theme(legend.position="bottom", legend.title = element_blank()) +
  scale_color_manual(values=cols_eco)

We see that the events with the highest economic damage were mainly floods, especially the one in late December 2005 / early January 2006. The second biggest contributor were wind events, especially Hurricane Katrina in 2005, but wind events in general and also floods/landslides have always been a main contributor to the total damage. All other event types never caused as much damage on property and crops as winds and floods.