Severe weather events can have both public health and economic consequences for the citizens. Those events can result in fatalities, injuries, and financial damages. The dataset provided by National Oceanic and Atmospheric Administration’s (NOAA) was used to analyse and visualise the damages in term of human health and economic damages.
# Load Data
data <- read.csv("./repdata_data_StormData.csv.bz2")
Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?
Across the United States, which types of events have the greatest economic consequences?
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
# Subset the data columns EVTYPE,PROPDMG,PROPDMGEXP,CROPDMG,CROPDMGEXP
subdata_econ <- data %>%
select(EVTYPE,PROPDMG,PROPDMGEXP,CROPDMG,CROPDMGEXP)
# Summarise the PROPDMG by EVTYPE and PROPDMGEXP
econ_sum <- subdata_econ %>%
group_by(EVTYPE, PROPDMGEXP) %>%
summarise(PROPDMG = sum(PROPDMG))
# Change the case and calcualte the damage
econ_damage <-
mutate(econ_sum, PropertyDamage = ifelse(
toupper(PROPDMGEXP) == 'K',
PROPDMG * 1000,
ifelse(
toupper(PROPDMGEXP) == 'M',
PROPDMG * 1000000,
ifelse(
toupper(PROPDMGEXP) == 'B',
PROPDMG * 1000000000,
ifelse(toupper(PROPDMGEXP) == 'H', PROPDMG * 100, PROPDMG)
)
)
))
## sort econ_damage descending PropertyDamage
desc_econ_damage <- econ_damage %>%
arrange(desc(PropertyDamage))
This is the result of top 10 harmful types base on the sum of casualties.
## Print the most harmful type of events
print(head(desc_harm_sum))
## # A tibble: 6 x 2
## EVTYPE Tot_Harm
## <chr> <dbl>
## 1 TORNADO 96979
## 2 EXCESSIVE HEAT 8428
## 3 TSTM WIND 7461
## 4 FLOOD 7259
## 5 LIGHTNING 6046
## 6 HEAT 3037
This is the plot base on previous stormData
## Loading required package: viridisLite
It is obvious that the tornado is the most dangerous phenomenon among the analysed
Here are the top 15 economic damages caused by event type
desc_econ_damage_15 <- desc_econ_damage[1:15,]
print(head(desc_econ_damage_15))
## # A tibble: 6 x 4
## # Groups: EVTYPE [5]
## EVTYPE PROPDMGEXP PROPDMG PropertyDamage
## <chr> <chr> <dbl> <dbl>
## 1 FLOOD B 122. 122500000000
## 2 HURRICANE/TYPHOON B 65.5 65500000000
## 3 TORNADO M 48462. 48462180000
## 4 STORM SURGE B 42.6 42560000000
## 5 FLOOD M 21279. 21279180000
## 6 FLASH FLOOD M 13735. 13734980000
This is the bar plot based on the Total damage
# Create the bar plot
tot_econ_plot <- ggplot(desc_econ_damage_15, aes(EVTYPE,PropertyDamage, fill=EVTYPE)) + geom_bar(stat="identity") + xlab("Top 15 events")+ ylab("Total Economic damage (15 most harmful events")+ ggtitle("Total Economic damage due to 15 most severe weather events in the U.S from 1950 to 2011") + theme(text = element_text(size=8),axis.text.x=element_text(angle=45,hjust=1))+
scale_fill_viridis(discrete = TRUE)
# Draw the bar plot
plot(tot_econ_plot)
The most damaging events are floods in economic terms