This document contains 3 elements:
In order to determine the most impactful type of cathastropic event when it comes to both human health as well as economic situation I had to design new measures. I could not use a simple sum of measure like fatalities because some events occured more frequently and therefore those would have higher value of sum. In sted of that I calculated measure per event so i divided the sum of for ex. fatalities for a particular event by the nr of times this event happend. This way I got a measure that allowed for a comparison of different events.
setwd("C:/Users/T540pDLEWYNBQ/Google Drive/Inne/Coursera/Reproducible Research/Assignment 2")
stormdata<-read.csv("FStormData.bz2")
library(dplyr)
FATALITIES_BY_EVTYPE<-stormdata %>%
group_by(EVTYPE) %>%
summarise("count"=n(),
"FATALITIES_SUM"=sum(FATALITIES, na.rm=T)) %>%
mutate("FATALITIES_PER_EVENT"=FATALITIES_SUM/count) %>%
arrange(FATALITIES_PER_EVENT) %>%
top_n(10,FATALITIES_PER_EVENT)
INJURIES_BY_EVTYPE<-stormdata %>%
group_by(EVTYPE) %>%
summarise("count"=n(),
"INJURIES_SUM"=sum(INJURIES, na.rm=T)) %>%
mutate("INJURIES_PER_EVENT"=INJURIES_SUM/count) %>%
arrange(INJURIES_PER_EVENT) %>%
top_n(10,INJURIES_PER_EVENT)
names<-FATALITIES_BY_EVTYPE$EVTYPE
FATALITIES_BY_EVTYPE$EVTYPE<-factor(FATALITIES_BY_EVTYPE$EVTYPE, levels = names)
names<-INJURIES_BY_EVTYPE$EVTYPE
INJURIES_BY_EVTYPE$EVTYPE<-factor(INJURIES_BY_EVTYPE$EVTYPE, levels = names)
PROPDMG_BY_EVTYPE<-stormdata %>%
group_by(EVTYPE) %>%
summarise("count"=n(),
"PROPDMG_SUM"=sum(PROPDMG, na.rm=T)) %>%
mutate("PROPDMG_PER_EVENT"=PROPDMG_SUM/count) %>%
arrange(PROPDMG_PER_EVENT) %>%
top_n(10,PROPDMG_PER_EVENT)
CROPDMG_BY_EVTYPE<-stormdata %>%
group_by(EVTYPE) %>%
summarise("count"=n(),
"CROPDMG_SUM"=sum(CROPDMG, na.rm=T)) %>%
mutate("CROPDMG_PER_EVENT"=CROPDMG_SUM/count) %>%
arrange(CROPDMG_PER_EVENT) %>%
top_n(10,CROPDMG_PER_EVENT)
names<-PROPDMG_BY_EVTYPE$EVTYPE
PROPDMG_BY_EVTYPE$EVTYPE<-factor(PROPDMG_BY_EVTYPE$EVTYPE, levels = names)
names<-CROPDMG_BY_EVTYPE$EVTYPE
CROPDMG_BY_EVTYPE$EVTYPE<-factor(CROPDMG_BY_EVTYPE$EVTYPE, levels = names)
Below you can find the list of top 10 most impactful catastrophic events when it comes to human fatalities and injuries.
library(ggplot2)
a<-ggplot(data=FATALITIES_BY_EVTYPE)+
geom_bar(aes(x=EVTYPE, y = FATALITIES_PER_EVENT), stat = "identity")+
coord_flip()+
ggtitle("FATALITIES PER EVENT")
b<-ggplot(data=INJURIES_BY_EVTYPE)+
geom_bar(aes(x=EVTYPE, y = INJURIES_PER_EVENT), stat = "identity")+
coord_flip()+
ggtitle("INJURIES PER EVENT")
multiplot(a,b, cols=2)
Below you can find the list of top 10 most impactful catastrophic events when it comes to propery damage and crop damage.
library(ggplot2)
a<-ggplot(data=PROPDMG_BY_EVTYPE)+
geom_bar(aes(x=EVTYPE, y = PROPDMG_PER_EVENT), stat = "identity")+
coord_flip()+
ggtitle("PROPERTY DAMAGE PER EVENT")
b<-ggplot(data=CROPDMG_BY_EVTYPE)+
geom_bar(aes(x=EVTYPE, y = CROPDMG_PER_EVENT), stat = "identity")+
coord_flip()+
ggtitle("CROP DAMAGE PER EVENT")
multiplot(a,b, cols=2)