This analysis explores the NOAA Storm Database to determine which weather events are most harmful to population health and which have the greatest economic consequences. Fatalities and injuries are used to measure health impact, while property and crop damage are used to measure economic impact. The results show that tornadoes cause the most harm to population health, while floods and hurricanes cause the greatest economic damage. These findings help prioritize disaster preparedness planning.
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)
storm_data <- read.csv("repdata-data-StormData.csv.bz2")
library(dplyr)
storm <- storm_data %>%
select(EVTYPE, FATALITIES, INJURIES,
PROPDMG, PROPDMGEXP,
CROPDMG, CROPDMGEXP)
health_impact <- storm %>%
group_by(EVTYPE) %>%
summarise(
TotalFatalities = sum(FATALITIES, na.rm = TRUE),
TotalInjuries = sum(INJURIES, na.rm = TRUE)
) %>%
mutate(TotalHarm = TotalFatalities + TotalInjuries) %>%
arrange(desc(TotalHarm))
top_health <- head(health_impact, 10)
top_health
## # A tibble: 10 × 4
## EVTYPE TotalFatalities TotalInjuries TotalHarm
## <chr> <dbl> <dbl> <dbl>
## 1 TORNADO 5633 91346 96979
## 2 EXCESSIVE HEAT 1903 6525 8428
## 3 TSTM WIND 504 6957 7461
## 4 FLOOD 470 6789 7259
## 5 LIGHTNING 816 5230 6046
## 6 HEAT 937 2100 3037
## 7 FLASH FLOOD 978 1777 2755
## 8 ICE STORM 89 1975 2064
## 9 THUNDERSTORM WIND 133 1488 1621
## 10 WINTER STORM 206 1321 1527
library(ggplot2)
ggplot(top_health, aes(x = reorder(EVTYPE, TotalHarm), y = TotalHarm)) +
geom_bar(stat = "identity") +
coord_flip() +
labs(title = "Top 10 Most Harmful Weather Events to Population Health",
x = "Event Type",
y = "Total Fatalities and Injuries")
storm$PROPDMGEXP <- as.character(storm$PROPDMGEXP)
storm$CROPDMGEXP <- as.character(storm$CROPDMGEXP)
storm$PROPDMGEXP[storm$PROPDMGEXP == "K"] <- 1000
storm$PROPDMGEXP[storm$PROPDMGEXP == "M"] <- 1000000
storm$PROPDMGEXP[storm$PROPDMGEXP == "B"] <- 1000000000
storm$PROPDMGEXP[!storm$PROPDMGEXP %in% c(1000,1000000,1000000000)] <- 1
storm$CROPDMGEXP[storm$CROPDMGEXP == "K"] <- 1000
storm$CROPDMGEXP[storm$CROPDMGEXP == "M"] <- 1000000
storm$CROPDMGEXP[storm$CROPDMGEXP == "B"] <- 1000000000
storm$CROPDMGEXP[!storm$CROPDMGEXP %in% c(1000,1000000,1000000000)] <- 1
storm$PROPDMGEXP <- as.numeric(storm$PROPDMGEXP)
storm$CROPDMGEXP <- as.numeric(storm$CROPDMGEXP)
storm$TotalDamage <- (storm$PROPDMG * storm$PROPDMGEXP) +
(storm$CROPDMG * storm$CROPDMGEXP)
economic_impact <- storm %>%
group_by(EVTYPE) %>%
summarise(TotalDamage = sum(TotalDamage, na.rm = TRUE)) %>%
arrange(desc(TotalDamage))
top_economic <- head(economic_impact, 10)
top_economic
## # A tibble: 10 × 2
## EVTYPE TotalDamage
## <chr> <dbl>
## 1 FLOOD 150319678257
## 2 HURRICANE/TYPHOON 71913712800
## 3 TORNADO 57340614060.
## 4 STORM SURGE 43323541000
## 5 HAIL 18752904943.
## 6 FLASH FLOOD 17562129167.
## 7 DROUGHT 15018672000
## 8 HURRICANE 14610229010
## 9 RIVER FLOOD 10148404500
## 10 ICE STORM 8967041360
ggplot(top_economic, aes(x = reorder(EVTYPE, TotalDamage), y = TotalDamage)) +
geom_bar(stat = "identity") +
coord_flip() +
labs(title = "Top 10 Weather Events Causing Economic Damage",
x = "Event Type",
y = "Total Economic Damage (USD)")