There are 2 variables that involve the population health the number of injuries (INJURIES) and the number of deaths (DEATHS) In order to summarise the data and answer our question we have to load the dplyr package
library("dplyr", lib.loc="~/R/win-library/3.2")
##
## Attaching package: 'dplyr'
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
Now will make a summary data by number of injuries grouped by event type and make a graph of the top five causes of injuries by natural catastrophes in the united states.
bad_health_injuries <- summarise(group_by(Storm.data, EVTYPE), Total_injuries=sum(INJURIES))
bad_health_injuries<-arrange (bad_health_injuries, desc(Total_injuries))
top_five_injuries <- bad_health_injuries[1:5,]
barplot(top_five_injuries$Total_injuries,names.arg=top_five_injuries$EVTYPE,cex.names=0.8, main="Number of injuries caused")
Now will make a summary data by number of deaths grouped by event type and make a graph of the top five causes of deaths by natural catastrophes in the united states.
bad_health_deaths <- summarise(group_by(Storm.data, EVTYPE), Total_deaths=sum(FATALITIES))
bad_health_deaths<-arrange (bad_health_deaths, desc(Total_deaths))
top_five_deaths <- bad_health_deaths[1:5,]
barplot(top_five_deaths$Total_deaths,names.arg=top_five_deaths$EVTYPE,cex.names=0.6, main="Number of Deaths caused")
In terms of economic losses the variables CROPDMG and PROPDMG acount for the estimated losses in dollars for crop damage and property damage respectibly. In our analysis economic losses are counted as the sum of properties and crop losses. We sum both losses and graph the top five natural disasters that cause more economic losses
Economic_loss <- summarise(group_by(Storm.data, EVTYPE), Total_loss=(sum(CROPDMG)+sum(PROPDMG)))
Economic_loss<-arrange (Economic_loss, desc(Total_loss))
top_five_loss <- Economic_loss[1:5,]
barplot(top_five_loss$Total_loss,names.arg=top_five_loss$EVTYPE,cex.names=0.8, main="Total economic loss")
Tornados are the only natural catastrophe in the top five in all three categories. Furthermore, they are the top cause of injuries, deaths and economic loss in the US and they always at least double the second cause.