This report explores the NOAA Storm Database to identify which severe weather events cause the most harm to population health and the economy. Using data from 1950 to 2011, we summarize fatalities, injuries, and economic damage. Tornadoes are found to be the most dangerous for health, while floods have the largest economic impact.
’’’{r setup, include=TRUE} library(dplyr) library(ggplot2) library(readr)
storm_data <- read.csv(bzfile(“repdata_data_StormData.csv.bz2”))
storm_subset <- storm_data %>% select(EVTYPE, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP, CROPDMG, CROPDMGEXP)
exp_map <- c("“=1,”K“=1e3,”M“=1e6,”B“=1e9,”k“=1e3,”m“=1e6,”b“=1e9,”0“=1,”1“=10,”2“=100,”3“=1e3,”4“=1e4,”5“=1e5,”6“=1e6,”7“=1e7,”8“=1e8,”9"=1e9)
storm_subset\(PROPDMGEXP <- toupper(storm_subset\)PROPDMGEXP) storm_subset\(CROPDMGEXP <- toupper(storm_subset\)CROPDMGEXP)
storm_subset <- storm_subset %>% mutate(PROPDMGVAL = PROPDMG * exp_map[PROPDMGEXP], CROPDMGVAL = CROPDMG * exp_map[CROPDMGEXP], TOTALDMG = PROPDMGVAL + CROPDMGVAL)
health_impact <- storm_subset %>% group_by(EVTYPE) %>% summarise(FATALITIES = sum(FATALITIES, na.rm=TRUE), INJURIES = sum(INJURIES, na.rm=TRUE)) %>% arrange(desc(FATALITIES + INJURIES))
economic_impact <- storm_subset %>% group_by(EVTYPE) %>% summarise(ECONOMICDMG = sum(TOTALDMG, na.rm=TRUE)) %>% arrange(desc(ECONOMICDMG))
top_health <- head(health_impact, 10)
ggplot(top_health, aes(x=reorder(EVTYPE, -(FATALITIES + INJURIES)))) + geom_bar(aes(y=FATALITIES), stat=“identity”, fill=“red”) + geom_bar(aes(y=INJURIES), stat=“identity”, fill=“orange”, alpha=0.6) + coord_flip() + labs(title=“Top 10 Weather Events Impacting Population Health”, y=“Total Health Impact”, x=“Event Type”)
top_economic <- head(economic_impact, 10)
ggplot(top_economic, aes(x=reorder(EVTYPE, -ECONOMICDMG), y=ECONOMICDMG/1e9)) + geom_bar(stat=“identity”, fill=“blue”) + coord_flip() + labs(title=“Top 10 Weather Events by Economic Damage”, y=“Damage (Billions USD)”, x=“Event Type”)