1 Synopsis

Within this analysis I will present you the following: * General data manipulation & analysis techniques we have learned during the Coursera Course “Reproducible Research” * The results from the analysis on United States Disaster Events * Methods on literate programming My analysis focuses on the Storm dataset from the National Climatic Data Center. It will show to you, that the most dangerous events in terms of injuries or fatalities are tornados in both overall history and the 21st century so far.

2 Data Processing

This sections describes data loading and processing in R studio.

## Loading required package: dplyr
## Warning: package 'dplyr' was built under R version 3.6.2
## 
## 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
## Loading required package: openxlsx
## Warning: package 'openxlsx' was built under R version 3.6.2
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.6.2
## Loading required package: xlsx
## Error: package or namespace load failed for 'xlsx':
##  .onLoad failed in loadNamespace() for 'rJava', details:
##   call: fun(libname, pkgname)
##   error: JAVA_HOME cannot be determined from the Registry
## Loading required package: lubridate
## Warning: package 'lubridate' was built under R version 3.6.2
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
## Loading required package: tidyr
## Warning: package 'tidyr' was built under R version 3.6.2
## Loading required package: markdown
## Warning: package 'markdown' was built under R version 3.6.2
## Loading required package: rmarkdown
## Warning: package 'rmarkdown' was built under R version 3.6.2
## Loading required package: plotly
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'plotly'
## Loading required package: stringr
## Warning: package 'stringr' was built under R version 3.6.2
## [[1]]
## [1] TRUE
## 
## [[2]]
## [1] TRUE
## 
## [[3]]
## [1] TRUE
## 
## [[4]]
## [1] FALSE
## 
## [[5]]
## [1] TRUE
## 
## [[6]]
## [1] TRUE
## 
## [[7]]
## [1] TRUE
## 
## [[8]]
## [1] TRUE
## 
## [[9]]
## [1] FALSE
## 
## [[10]]
## [1] TRUE

Download and import Dataset

# Download dataset
download.file(url = "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
              ,destfile = "StormData.csv")

# Import dataset
Rawdata<-read.csv2(file = "StormData.csv",header = TRUE,sep = ",",dec = ".")%>%
        separate(col = BGN_DATE,into = c("Month","Day","Year"),remove = FALSE)
## Warning: Expected 3 pieces. Additional pieces discarded in 902297 rows [1, 2, 3,
## 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...].

Create first aggregated insights

# Create aggregated results
Event_Counts<-Rawdata%>%group_by(EVTYPE)%>%summarise(count = n())%>%arrange(desc(count))

# Which are the most harmful eventS in general?
head(Event_Counts)
## # A tibble: 6 x 2
##   EVTYPE             count
##   <fct>              <int>
## 1 HAIL              288661
## 2 TSTM WIND         219940
## 3 THUNDERSTORM WIND  82563
## 4 TORNADO            60652
## 5 FLASH FLOOD        54277
## 6 FLOOD              25326

Aggegregates on Event Types

# Create aggregated data
Public_Health_Damages_overall<-Rawdata%>%group_by(EVTYPE)%>%summarise(Fatalities = sum(FATALITIES), Injuries = sum(INJURIES))%>%arrange(desc(Fatalities))

head(Public_Health_Damages_overall)
## # A tibble: 6 x 3
##   EVTYPE         Fatalities Injuries
##   <fct>               <dbl>    <dbl>
## 1 TORNADO              5633    91346
## 2 EXCESSIVE HEAT       1903     6525
## 3 FLASH FLOOD           978     1777
## 4 HEAT                  937     2100
## 5 LIGHTNING             816     5230
## 6 TSTM WIND             504     6957

Tornados are the most harmful disaster events

–> Is it necessary to exclude outliers from the dataset?

No heavy outliers in fatalities in terms of absolute numbers –> no necessarity to exclude a Tornado with 150 fatalities from dataset Same argumentation for ~1700 injuries

3 Results

Results and conclusions made on the prepared data.

# Graphs - all observations

ggplot(data = head(Public_Health_Damages_overall), aes(x = EVTYPE, y = Fatalities))+
        geom_col(fill = "darkblue")+
        theme(axis.text.x = element_text(angle=90, size=10, face="bold")
              ,axis.text.y = element_text(size= 10, face= "bold")
              ,title = element_text(size=25)
              
              ,legend.text = element_text(size= 15))+
        ggtitle("Most harmful Disaster Events - Fatalities")

ggplot(data = head(Public_Health_Damages_overall), aes(x = EVTYPE, y = Injuries))+
        geom_col(fill = "darkblue")+
        theme(axis.text.x = element_text(angle=90, size=10, face="bold")
              ,axis.text.y = element_text(size= 10, face= "bold")
              ,title = element_text(size=25)
              ,legend.text = element_text(size= 15))+
        ggtitle("Most harmful Disaster Events - Injuries")

The data shows that Tornados are the most harmful natural disaster events in the United States in both terms of injuries and terms of fatatlities.

3.1 End of Analysis

4 Alternative analysis

Filter View on 21st century

# analysis filtered on 21st century data only

Public_Health_Damages_21st<-Rawdata%>%filter(Year >= 2000)%>%group_by(EVTYPE)%>%
                summarise(Fatalities = sum(FATALITIES), Injuries = sum(INJURIES))%>%arrange(desc(Fatalities))

ggplot(data = head(Public_Health_Damages_21st), aes(x = EVTYPE, y = Fatalities))+ geom_col(fill = “darkblue”)+ theme(axis.text.x = element_text(angle=90, size=10, face=“bold”) ,axis.text.y = element_text(size= 10, face= “bold”) ,title = element_text(size=25) ,legend.text = element_text(size= 15))+ ggtitle(“Most harmful Disaster Events in 21st century - Fatalities”)

ggplot(data = head(Public_Health_Damages_21st), aes(x = EVTYPE, y = Injuries))+ geom_col(fill = “darkblue”)+ theme(axis.text.x = element_text(angle=90, size=10, face=“bold”) ,axis.text.y = element_text(size= 10, face= “bold”) ,title = element_text(size=25) ,legend.text = element_text(size= 15))+ ggtitle(“Most harmful Disaster Events in 21st century - Injuries”)