Abstract

Main questions that this report sets out to answer are:

What is found is that the most harmful events regarding the populations health is tornados. The events with the greatest economic consequences is flooding.

Data Processing and Synopsis

First I load the data and get some parameters that describe the data.

library("lubridate")
## Warning: package 'lubridate' was built under R version 4.3.3
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
ed<-read.csv("repdata_data_StormData.csv")
variables<-as.numeric(ncol(ed))
observations<- nrow(ed)
event_count<-length(unique(ed$EVTYPE))
ed$BGN_DATE <- as.POSIXct(as.character(ed$BGN_DATE), format = "%m/%d/%Y %H:%M:%S")
Fyear<-min(year(ed$BGN_DATE))
Lyear<-max(year(ed$BGN_DATE))

This data set has 902,297 observations spanning between 1950 and 2011, across states and territories of the United States. There are 985 event types included in this data set including hail, tornados, and blizzards for example.These events have had many impacts to American communities such as damages to crops, properties as well as injuries and fatalities.This data set over these and other dimensions in a total of37 variables.

To estimate the total damage lost, the PROPDMGEXP and CROPDMGEXP is converted to a numeric class and replaced using the property damage exponent translation found here.

ed[ed$PROPDMGEXP == "K",]$PROPDMGEXP <- 1000 
ed[ed$PROPDMGEXP == "M",]$PROPDMGEXP <- 1000000
ed[ed$PROPDMGEXP == "m",]$PROPDMGEXP <- 1000000
ed[ed$PROPDMGEXP == "B",]$PROPDMGEXP <- 1000000000
ed[ed$PROPDMGEXP == "H",]$PROPDMGEXP <- 100
ed[ed$PROPDMGEXP == "h",]$PROPDMGEXP <- 100
ed[ed$PROPDMGEXP == "+",]$PROPDMGEXP <- 1
ed[ed$PROPDMGEXP == "-",]$PROPDMGEXP <- 0
ed[ed$PROPDMGEXP == "?",]$PROPDMGEXP <- 0
ed[ed$PROPDMGEXP == "",]$PROPDMGEXP <- 0
ed[ed$PROPDMGEXP %in% 1:10,]$PROPDMGEXP <- 10
ed[ed$PROPDMGEXP == "0",]$PROPDMGEXP <- 10
ed[ed$CROPDMGEXP == "K",]$CROPDMGEXP <- 1000 
ed[ed$CROPDMGEXP == "k",]$CROPDMGEXP <- 1000
ed[ed$CROPDMGEXP == "M",]$CROPDMGEXP <- 1000000
ed[ed$CROPDMGEXP == "m",]$CROPDMGEXP <- 1000000
ed[ed$CROPDMGEXP == "B",]$CROPDMGEXP <- 1000000000
ed[ed$CROPDMGEXP == "?",]$CROPDMGEXP <- 0
ed[ed$CROPDMGEXP == "",]$CROPDMGEXP <- 0
ed[ed$CROPDMGEXP %in% 1:10,]$CROPDMGEXP <- 10
ed[ed$CROPDMGEXP == "0",]$CROPDMGEXP <- 10
ed$PROPDMGEXP <- as.numeric(ed$PROPDMGEXP)
ed$CROPDMGEXP <- as.numeric(ed$CROPDMGEXP)

Economic Damage transformation

To determine the economic impact of an event, an event label in concatenated from the date, the state and the event.

#Ten Most Harmful single events for fatalities and Injuries
ed$details <- paste(ed$BGN_DATE, ed$STATE, ed$EVTYPE)

Population Health transformation

To determine the event the impact of an event on the population’s health, the total number of fatalities and injuries are processed in the same way. For both impact measures the totals per event type are calculated and sorted in descending order. This produces a list for each measure of the most impactful event.

#Fatalities
FatDamage<-tapply(ed$FATALITIES,ed$EVTYPE, sum)
FatDamage<-sort(FatDamage, decreasing = TRUE)
FatDamage<-as.data.frame(FatDamage)
colnames(FatDamage)<- "Total Fatalities"
Ftable<-head(FatDamage, n=10)
#Injuries
InjDamage<-tapply(ed$INJURIES,ed$EVTYPE, sum)
InjDamage<-sort(InjDamage, decreasing = TRUE)
InjDamage<-as.data.frame(InjDamage)
colnames(InjDamage)<- "Total Injuries"
Itable<-head(InjDamage, n=10)

Economic Impact transformation

To determine the impact of the economic damages, using the translated property and crop unit of measure. First the property damages is calculated by multiplying the damage estimate by the property unit of measure and then the crop damage is calculated by multiplying the estimated crop damage by the crop unit of measure. The total damage is calculated by adding the total estimate for the crop damage and the property damage together. Then the total estimated economic damage is tallied for event type, which is then sorted in descending order.

#Find Damage
ed$PROPDMGSIZE <- ed$PROPDMG * ed$PROPDMGEXP 
ed$CROPDMGSIZE <- ed$CROPDMG * ed$CROPDMGEXP
#Total DMG
ed$TOTDMG <- ed$PROPDMGSIZE + ed$CROPDMGSIZE
#Sum Over Event Types
DMGTable <- tapply(ed$TOTDMG, ed$EVTYPE, sum)
TTDMGTable <- head(sort(DMGTable/1000000000, decreasing = TRUE), n = 10)

Results

Population Health Impacts: Which events are the most harmful?

The charts below show the top ten events which cause fatalities (in red on the left) and injuries (in orange on the right). In these charts its clear that the event which has caused the most harm to the US’s health is Tornados.

#Figure 1
#2 Plots
par(mfrow = c(1,2))
par(mar= c(9,4,1,2))
barplot(Ftable[,1], names.arg = rownames(Ftable), main = "Top Ten Types of Event By Fatalities", cex.main = 0.7, las = 2, col ="darkred"  )
barplot(Itable[,1], names.arg = rownames(Itable), main = "Top Ten Types of Event By Injuries", cex.main = 0.7, las = 2, col = "darkorange"  )

Economic Damage Impacts: Which events have the greatest economic consequences?

The chart below shows the top ten events which cause the largest. This chart demonstrates that the events which have caused the greatest economic damages are floods.

par(mfrow = c(1,1))
par(oma = c(1,1,1,1))
barplot(TTDMGTable, names.arg = names(TTDMGTable), las = 2, main = "Ten Most Damaging Event Types By Economic Damage",
        ylab = "Total Damage (Billions of USD)", col = "darkblue", cex.names = 0.7)