Severe weather events have a huge impact on population health and economic growth, In this analysis, we aim to list severe weather events by their impact on population health and economy, the data is provided by the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database, which provides data about the number of injuries and fatalities for each type of event, and also the cost of property damage and crop damage, the result of this analysis is a list of the most dangerous severe weather events with respect of their economic consequences.
Information about the data :
Getting and cleaning the data,than filling empty cells with NA’s.
library(dplyr)
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2",destfile = "StormData.csv.bz2")
df<-read.csv("StormData.csv.bz2",na.strings = "")
I selected the variables FATALITIES and INJURIES which relates to the health effects of the weather events types then assigned it to the health_effects data frame,than i did the same transformation to the variables PROPDMG and CROPDMG which relates to the economic effects of the weather events and assigned it to the economic_effects data frame,than i grouped each data frame by the EVTYPE variable then summed up the total injuries and the total fatalities and the total property damage and the total crop damage for each event type than i added two variables to each data frame, which are the relative frequencies,and finally arranged the dataframes by the relative frequencies.
health_effects <- df%>%select(STATE,EVTYPE,FATALITIES,INJURIES)%>%group_by(EVTYPE)%>%
summarise(Tot_injuries=sum(INJURIES),Tot_fatalities=sum(FATALITIES))%>%
mutate(injuries_freq=round(100*(Tot_injuries/sum(Tot_injuries))),fatalities_freq=round(100*(Tot_fatalities/sum(Tot_fatalities))))%>%arrange(desc(fatalities_freq),desc(injuries_freq))
economic_effects<-df %>% select(STATE,EVTYPE,PROPDMG,CROPDMG)%>%group_by(EVTYPE)%>%
summarise(Tot_propdmg=sum(PROPDMG),Tot_cropdmg=sum(CROPDMG))%>%
mutate(propdmg_freq=round(100*(Tot_propdmg/sum(Tot_propdmg))),croppdmg_freq=round(100*(Tot_cropdmg/sum(Tot_cropdmg))))%>% arrange(desc(propdmg_freq),desc(croppdmg_freq))
par(mar=c(3.5,10,1,1))
barplot(t(as.matrix(health_effects[20:1, 4:5])),
names.arg = health_effects$EVTYPE[20:1],
beside = TRUE,
xlim = c(0,10),
xlab = "Relative frequency in %",
las=1 ,horiz = 2,
col=c("orange","red"),
main ="Population health most affecting severe weather events ")
legend("bottomright",
legend = c("Fatalities","Injuries"),
col = c("red", "orange"),
pch = c(19,19),
bty = "n",
pt.cex = 1.6,
cex = 1,
text.col = "black",
horiz = F ,
inset = c(0.1, 0.1))
The graph above shows the top most effecting severs weather events on the population health,the first remarks are :
par(mar=c(5,10,2,1))
barplot(t(as.matrix(economic_effects[25:1, 4:5])),
names.arg = economic_effects$EVTYPE[25:1],
beside = TRUE,
xlim = c(0,14),
xlab = "Relative frequency in %",
las=1 ,horiz = 2,
col=c("grey", "#006400"),
main ="Economic most effecting severe weather events")
legend("right",
legend = c("Property damage","Crop damage"),
col = c("grey", "#006400"),
pch = c(19,19),
bty = "n",
pt.cex = 1.6,
cex = 1,
text.col = "black",
horiz = F ,
inset = c(0.1, 0.1))
The graph above shows the top most effecting severe weather events on the Economy,the first remarks are :