HARMFUL STORMS AND WEATHER EVENTS IN THE USA (1950-2011)

SYNOPSIS

The United States as a Trans-climatic Country experiences both Temperate and Tropical storm and weather events and has in recent times began to experience anomalies of polar origin as a function of global Climate Change. Every year, these events reek economic and health havoc across the US costing millions of Dollars in property and Crop Damage as well as precious American lives.
From Tornadoes/Typhoons and thunderstorms to Volcanic ash and dust storms, the US has since time immemorial gone through an annual cycle of destruction and construction as a function of storm and weather events.
This is a report on the ten most destructive of these events as a measure of their consequences on population health and economy between the years 1950 and 2011.

DATA PROCESSING

#Working Directory
setwd("F:/R_PROJECTS/Reproducible Research/Project 2")

#Downloading data from the internet
download.file(
       "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2",
       destfile = "F:/R_PROJECTS/Reproducible Research/Project 2/storm_data.bz2",
       method = "curl"
)

#Connecting to the downloaded file (bzip2 file) for data import
con <- bzfile(dir(pattern = "storm_data.bz2"))
storm_data <- read.csv(
       con
)

#Conversion of "BGN_DATE" to Date-time-class object for R to recognize it as a date-time object
date <- strptime(
       storm_data[ ,"BGN_DATE"], 
       format = "%m/%d/%Y %H:%M:%S"
)
storm_data$BGN_DATE <- date

RESULTS

Harmful Events With Respect To Population Health

suppressMessages(require(tidyverse))

#harmful events in terms of population health as suggested in the storm weather documentation
pop_hlth <- c(
       storm_data$EVTYPE[grepl("[Cc][Oo][Ll][Dd]", storm_data$EVTYPE)],
       storm_data$EVTYPE[grepl("[Dd][Uu][Ss][Tt]", storm_data$EVTYPE)],
       storm_data$EVTYPE[grepl("[Hh][Ee][Aa][Tt]", storm_data$EVTYPE)],
       storm_data$EVTYPE[grepl("[Ff][Rr][Ee][Ee][Zz]", storm_data$EVTYPE)],
       storm_data$EVTYPE[grepl("[Vv][Oo][Ll][Cc][Aa][Nn][Ii][Cc]", storm_data$EVTYPE)],
       storm_data$EVTYPE[grepl("[Ww][Ii][Ll][Dd] [Ff][Ii][Rr][Ee]", storm_data$EVTYPE)]
)

storm_data[
  (storm_data$EVTYPE %in%pop_hlth),c("BGN_DATE","STATE","EVTYPE","FATALITIES","INJURIES")
  ] -> pop_hth; pop_hth$EVTYPE <- tolower(pop_hth$EVTYPE)

#aggregating "FATALITIES" and "INJURIES" as a function of "EVTYPE" excluding 0s
FATALITIES <- aggregate(FATALITIES ~ EVTYPE, data = pop_hth, sum, na.rm = T) %>% 
        filter(FATALITIES > 0) %>% 
        rename(event_type = EVTYPE) %>% 
        arrange(desc(FATALITIES))

INJURIES <- aggregate(INJURIES ~ EVTYPE, data = pop_hth, sum, na.rm = T) %>% 
        filter(INJURIES > 0) %>% 
        rename(event_type = EVTYPE) %>% 
        arrange(desc(INJURIES))


#Converting Variable "EVTYPE" to categorical for a colors on the graph to map a specific event
FATALITIES[,1] <- as.factor(FATALITIES[,1]);INJURIES[,1] <- as.factor(INJURIES[,1])

# plot Matrix
gridExtra::grid.arrange(
        ggplot(data = FATALITIES[1:10,], aes(x = 1:10, y = FATALITIES)) + 
                geom_point(aes(col = event_type), size = 4) + 
                geom_line() +
                labs(x = "", y = "count", subtitle = "FATALITIES" ,
                     title = "EVENTS WITH MOST EFFECT ON POPULATION HEALTH,USA-(1950-2011) ") +
                theme(plot.subtitle = element_text(size = 16.5),
                      plot.title = element_text(size = 20, face = "bold", hjust = 0.5),
                      axis.title = element_text(face = "italic", size = 17),
                      axis.text = element_text(size = 14),
                      legend.text = element_text(size = 18),
                      legend.title = element_text(size = 18),
                      axis.text.x = element_blank(),
                      axis.ticks.x = element_blank()),
        
        ggplot(data = INJURIES[1:10,], aes(x = 1:10, y = INJURIES)) + 
                geom_point(aes(col = event_type), size = 4) + 
                geom_line() +
                labs(x = "", y = "count", subtitle = "INJURIES") + 
                theme(axis.title = element_text(face = "italic",size = 17),
                      axis.text = element_text(size = 14),
                      plot.subtitle = element_text(size = 16.5),
                      legend.text = element_text(size = 18),
                      legend.title = element_text(size = 18),
                      axis.text.x = element_blank(),
                      axis.ticks.x = element_blank())
)

The plot above shows how storm and weather events have affect population health in terms of fatalities and injuries they reek between the years 1950 and 2011. The first plot illustrates the top 10 events with the most fatalities whereas the second plot presents the top ten events with the most injuries reeked. In all cases, excessive heat dominated casualties

Events with Greatest Economic Consequences

#From the storm data documentation, some identified population health-harmful events 
#intersect with those identified to be economically detrimental, the ff code tries to 
#make sure all intersections are in the analysis. 
c(storm_data$EVTYPE[grepl("[Dd][Uu][Ss][Tt] [Ss][Tt][Oo][Rr][Mm]", storm_data$EVTYPE)],
  storm_data$EVTYPE[grepl("[Ee][Xx][Tt][Rr][Ee][Mm][Ee] [Cc][Oo][Ll][Dd]", storm_data$EVTYPE)],
  storm_data$EVTYPE[grepl("[Ff][Rr][Ee][Ee][Zz][Ii][Nn][Gg] [Ff][Oo][Gg]", storm_data$EVTYPE)],
  storm_data$EVTYPE[grepl("[Ff][Rr][Oo][Ss][Tt] [Ff][Rr][Ee][Ee][Zz][Ee]", storm_data$EVTYPE)]
) -> int
pop_hlth_1 <- pop_hlth[!(pop_hlth %in% int)] 

#Extracting storm/weather events with Economic consequences
ec_conseq <- storm_data[
  !(storm_data$EVTYPE %in% pop_hlth_1) ,c("BGN_DATE","STATE","EVTYPE","PROPDMG","CROPDMG")
  ]

#Converting all elements of the "EVTYPE" variable to lower case to remove a case variations
ec_conseq$EVTYPE <- tolower(ec_conseq$EVTYPE)

#Removing all EVTYPES represented by meta characters 
ec_conseq <- ec_conseq[(grepl("^[a-zA-Z]", ec_conseq$EVTYPE)), ]

#Aggregating Property Damage by each storm/weather as a function of event
PROPDMG <- aggregate(PROPDMG ~ EVTYPE, data = ec_conseq, sum, na.rm = T) %>% 
        filter(PROPDMG > 0) %>% 
        rename(Property_Damage = PROPDMG) %>% 
        arrange(desc(Property_Damage))

#Aggregating Crop Damage by each storm/weather as a function of event
CROPDMG <- aggregate(CROPDMG ~ EVTYPE, data = ec_conseq, sum, na.rm = T) %>% 
        filter(CROPDMG > 0) %>% 
        rename(Crop_Damage = CROPDMG) %>% 
        arrange(desc(Crop_Damage))

#Converting variable "EVTYPE" to  categorical for a colors on the graph to map a specific event
PROPDMG[,1] <- factor(PROPDMG[,1]);CROPDMG[,1] <- factor(CROPDMG[,1])

#Plot Matrix
gridExtra::grid.arrange(
        ggplot(data = PROPDMG[1:10, ], aes(x = 1:10, y = Property_Damage)) +
                geom_point(aes(col = EVTYPE),size = 4) + 
                geom_line() +
                labs(x = "", y = "Damage ($)", 
                subtitle = "PROPERTY DAMAGE", 
                title = "EVENTS WITH MOST ECONOMIC CONSEQUENCES,USA-(1950-2011)") +
                theme(plot.subtitle = element_text(size = 16.5),
                      plot.title = element_text(size = 20, face = "bold", hjust = 0.5),
                      axis.title = element_text(face = "italic", size = 17),
                      axis.text = element_text(size = 15),
                      legend.text = element_text(size = 18),
                      legend.title = element_text(size = 18),
                      axis.text.x = element_blank(),
                      axis.ticks.x = element_blank()),
              
        
        ggplot(data = CROPDMG[1:10, ], aes(x = 1:10, y = Crop_Damage)) + 
                geom_point(aes(col = EVTYPE), size = 4) +
                geom_line() + 
                labs(x = "", y = "Damage ($)", 
                     subtitle = "CROP DAMAGE") + 
                theme(plot.subtitle = element_text(size = 16.5),
                      axis.title = element_text(face = "italic", size = 17),
                      axis.text = element_text(size = 15),
                      legend.text = element_text(size = 18),
                      legend.title = element_text(size = 18),
                      axis.text.x = element_blank(),
                      axis.ticks.x = element_blank())
)

The economic consequences of havoc and damage to properties by storm and weather events in the US amounts in millions of dollars. From the graph, the most damage to property is caused by Tornadoes towering over 2.5 million dollars between the said time period. The most Crop Damage on the hand is caused by hail, amounting over 400,000 dollars in monetary value.