The purpose of this document is to highlight the financial and physical damage caused by hydro-meteorological events in the USA. Where fincancial damag is defined as the property damage and physical damage is defined as fatalities and injuries caused by hydro-meteorological events. The data source for this piece of research is the Storm Data collected and provided by the National Oceanic and Atmospheric Administration (NOAA).
#getting packages
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.1
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(gridExtra)
## Warning: package 'gridExtra' was built under R version 3.4.1
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
#Set Working Directore
setwd("/Users/mebner/Documents/for_me/R_coursera/GitHub/reproducable_research_peerassessment2")
#get raw data
storm_raw <- read.csv("repdata%2Fdata%2FStormData.csv")
The exporatory variable I’m using in the following is EVTYPE and describes the event type. The values of the variable do not follow a strict naming conventions and therefore as a first step I have to aggregate the event types to distinct groups.
storm_tidy <- storm_raw[,c("EVTYPE","FATALITIES","INJURIES","PROPDMG")]
storm_tidy <- storm_tidy %>% filter(FATALITIES > 0 | INJURIES > 0 | PROPDMG >0)
storm_tidy$clean_event <- ifelse(grepl("tsunami|coastal flood|coastal erosion|tidal flooding",storm_tidy$EVTYPE,ignore.case = T),'coastal flooding',
ifelse(grepl("flood|rapidly rising water|urban.*small|seiche|stream fld",storm_tidy$EVTYPE,ignore.case = T),'inland flooding',
ifelse(grepl("high water|seas|surf|current|wave|tide|coastal surge",storm_tidy$EVTYPE,ignore.case = T),'heavy seas and tidal events',
ifelse(grepl("^fog",storm_tidy$EVTYPE,ignore.case = T),'fog',
ifelse(grepl("gustnado|tornado|torndao|hurricane|typhoon|waterspout|dust devil|dust.*storm|blowing dust",storm_tidy$EVTYPE,ignore.case = T),'heavy storms',
ifelse(grepl("landslide|mud.*slide|rock slide",storm_tidy$EVTYPE,ignore.case = T),'land slides',
ifelse(grepl("lightning|ligntning|lighting",storm_tidy$EVTYPE,ignore.case = T),'lightnings',
ifelse(grepl("hail",storm_tidy$EVTYPE,ignore.case = T),'hail',
ifelse(grepl("rain|shower|thunderstorm|tropical depression|storm|precip",storm_tidy$EVTYPE,ignore.case = T),'modarate storms',
ifelse(grepl("wind|turbulence|microburst",storm_tidy$EVTYPE,ignore.case = T),'wind',
ifelse(grepl("winter weather|wintry|hypothermia|icy|cold|freez|frost|glaze|snow|ice|sleet|low temperature|blizzard|HEAVY SNOW\\/BLIZZARD\\/AVALANCHE",storm_tidy$EVTYPE,ignore.case = T),'cold, ice and snow',
ifelse(grepl("avalanc.*e",storm_tidy$EVTYPE,ignore.case = T),'avalanches',
ifelse(grepl("dry|heat|warm|drought|fire",storm_tidy$EVTYPE,ignore.case = T),'dry, heat and fire','others')))))))))))))
storm_tidy <- storm_tidy[,c("clean_event","FATALITIES","INJURIES","PROPDMG")]
storm_tidy <- storm_tidy %>% group_by(clean_event) %>% summarise_all(funs(sum))
ggplot(storm_tidy,aes(x=reorder(clean_event,FATALITIES),y=FATALITIES/1000))+
geom_bar(colour="#4C9AFF",fill="#4C9AFF", stat="identity")+
labs(title ="Fatalities\n(in thousand)",
x = "",
y = "")+
scale_y_continuous(breaks = seq(0,6, by = 1), limits = c(0,6))+
theme(axis.text.x = element_text(angle = 45, hjust = 1,size=6))
ggplot(storm_tidy,aes(x=reorder(clean_event,INJURIES),y=INJURIES/1000))+
geom_bar(colour="#0052CC",fill="#0052CC", stat="identity")+
labs(title = "Injuries\n(in thousand)",
x = "",
y = "") +
scale_y_continuous(breaks = seq(0,100, by = 10), limits = c(0,100))+
theme(axis.text.x = element_text(angle = 45, hjust = 1,size=6))
ggplot(storm_tidy,aes(x=reorder(clean_event,PROPDMG),y=PROPDMG/1000000))+
geom_bar(colour="#FF8B00",fill="#FF8B00", stat="identity")+
labs(title = "Property Damage\n(in million U.S. dollars",
x = "",
y = "") +
scale_y_continuous(breaks = seq(0,3.5, by = 0.5), limits = c(0,3.5))+
theme(axis.text.x = element_text(angle = 45, hjust = 1,size=6))
In the plots above one can see the grouped meteorlogical events by fatalities, injuries and the property damage they’ve caused. Heavy storms such as Hurricanes or Tornados are on the top of the rankings for all three metrics. When it comes to physical damage heavy storms are by far the most devestating events. Not so much when it comes to property damage. Inland floodings cause quite some damage in that area too.