Synposis: This analysis is done to identify health and economic
problems faced by municipalities/communities across United States during
natural catastrophes like storm, wildfire etc.. by answering the below
two questions:
1. Across the United States, which types of events are most harmful
with respect to population health?
2. Across the United States, which types of events have the greatest
economic consequences?
library(tidyr)
library(dplyr)
##
## 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)
Data Processing
storm_data <- read.csv('repdata_data_StormData.csv.bz2',header = TRUE)
names(storm_data)
## [1] "STATE__" "BGN_DATE" "BGN_TIME" "TIME_ZONE" "COUNTY"
## [6] "COUNTYNAME" "STATE" "EVTYPE" "BGN_RANGE" "BGN_AZI"
## [11] "BGN_LOCATI" "END_DATE" "END_TIME" "COUNTY_END" "COUNTYENDN"
## [16] "END_RANGE" "END_AZI" "END_LOCATI" "LENGTH" "WIDTH"
## [21] "F" "MAG" "FATALITIES" "INJURIES" "PROPDMG"
## [26] "PROPDMGEXP" "CROPDMG" "CROPDMGEXP" "WFO" "STATEOFFIC"
## [31] "ZONENAMES" "LATITUDE" "LONGITUDE" "LATITUDE_E" "LONGITUDE_"
## [36] "REMARKS" "REFNUM"
Analysing Harmful Events
Categorising fatalities and injuries under one column and their
values in another column
gather_data <- gather(most_harmful_data,type,value,FATALITIES:INJURIES)
print(gather_data)
## # A tibble: 20 × 3
## EVTYPE type value
## <chr> <chr> <dbl>
## 1 TORNADO FATALITIES 5633
## 2 EXCESSIVE HEAT FATALITIES 1903
## 3 TSTM WIND FATALITIES 504
## 4 FLOOD FATALITIES 470
## 5 LIGHTNING FATALITIES 816
## 6 HEAT FATALITIES 937
## 7 FLASH FLOOD FATALITIES 978
## 8 ICE STORM FATALITIES 89
## 9 THUNDERSTORM WIND FATALITIES 133
## 10 WINTER STORM FATALITIES 206
## 11 TORNADO INJURIES 91346
## 12 EXCESSIVE HEAT INJURIES 6525
## 13 TSTM WIND INJURIES 6957
## 14 FLOOD INJURIES 6789
## 15 LIGHTNING INJURIES 5230
## 16 HEAT INJURIES 2100
## 17 FLASH FLOOD INJURIES 1777
## 18 ICE STORM INJURIES 1975
## 19 THUNDERSTORM WIND INJURIES 1488
## 20 WINTER STORM INJURIES 1321
Analysing Economic Consquences
Grouping and summarising crop and property damage expenses
economy_data <- storm_data %>% group_by(EVTYPE) %>% summarize(PROPDMGVALUE=sum(PROPDMGVALUE),CROPDMGVALUE = sum(CROPDMGVALUE)) %>% arrange(desc(PROPDMGVALUE+CROPDMGVALUE))
Extracting the top 10 economic losses and plotting
most_economy_loss <- economy_data[1:10,]
economy_gather_data <- gather(most_economy_loss,type,value,PROPDMGVALUE:CROPDMGVALUE)
ggplot(economy_gather_data,aes(y=reorder(EVTYPE,-value),x=value,fill=type)) + geom_bar(stat="identity") + xlab("Count of crop/property damage") + ylab("Events") + ggtitle("Economic Harmful Events")

Results:
Based on the data analysis,the below results were inferred.
1. Tornado is the most harmful event with respect to the
health.
2. Flood has the greatest economic consequences.