library(dplyr)
library(ggplot2)
storm <- read.csv("repdata_data_StormData.csv.bz2", stringsAsFactors = FALSE)
dim(storm)
## [1] 902297 37
head(storm)
## STATE__ BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE EVTYPE
## 1 1 4/18/1950 0:00:00 0130 CST 97 MOBILE AL TORNADO
## 2 1 4/18/1950 0:00:00 0145 CST 3 BALDWIN AL TORNADO
## 3 1 2/20/1951 0:00:00 1600 CST 57 FAYETTE AL TORNADO
## 4 1 6/8/1951 0:00:00 0900 CST 89 MADISON AL TORNADO
## 5 1 11/15/1951 0:00:00 1500 CST 43 CULLMAN AL TORNADO
## 6 1 11/15/1951 0:00:00 2000 CST 77 LAUDERDALE AL TORNADO
## BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END COUNTYENDN
## 1 0 0 NA
## 2 0 0 NA
## 3 0 0 NA
## 4 0 0 NA
## 5 0 0 NA
## 6 0 0 NA
## END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES INJURIES PROPDMG
## 1 0 14.0 100 3 0 0 15 25.0
## 2 0 2.0 150 2 0 0 0 2.5
## 3 0 0.1 123 2 0 0 2 25.0
## 4 0 0.0 100 2 0 0 2 2.5
## 5 0 0.0 150 2 0 0 2 2.5
## 6 0 1.5 177 2 0 0 6 2.5
## PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES LATITUDE LONGITUDE
## 1 K 0 3040 8812
## 2 K 0 3042 8755
## 3 K 0 3340 8742
## 4 K 0 3458 8626
## 5 K 0 3412 8642
## 6 K 0 3450 8748
## LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1 3051 8806 1
## 2 0 0 2
## 3 0 0 3
## 4 0 0 4
## 5 0 0 5
## 6 0 0 6
This analysis examines the NOAA Storm Database to identify the weather event types that caused the greatest harm to population health and the greatest economic damage in the United States. Population health impact was measured using total fatalities and injuries. Economic impact was measured using total property and crop damage.
The NOAA Storm Database was loaded into R from the compressed CSV
file. Event types were grouped using the EVTYPE variable.
For population health, fatalities and injuries were summed for each
event type. For economic damage, property and crop damage values were
converted according to their exponent codes: K for thousands, M for
millions, and B for billions.
health <- storm %>% group_by(EVTYPE) %>%
summarise(fatalities = sum(FATALITIES, na.rm = TRUE), injuries = sum(INJURIES, na.rm = TRUE)) %>% mutate(total_health = fatalities + injuries) %>% arrange(desc(total_health))
head(health, 10)
## # A tibble: 10 × 4
## EVTYPE fatalities injuries total_health
## <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
top_health <- head(health, 10)
ggplot(top_health,aes(x = reorder(EVTYPE, total_health),y = total_health)) + geom_col(fill = "steelblue") + coord_flip() + labs(title = "Top 10 Weather Events Harmful to Population Health", x = "Event Type", y = "Total Fatalities and Injuries")
## Economic Impact
storm$PROPDMGEXP <- toupper(storm$PROPDMGEXP)
storm$CROPDMGEXP <- toupper(storm$CROPDMGEXP)
storm$PROPDMGVALUE <- ifelse(storm$PROPDMGEXP == "K",
storm$PROPDMG * 1000,
ifelse(storm$PROPDMGEXP == "M",
storm$PROPDMG * 1e6,
ifelse(storm$PROPDMGEXP == "B",
storm$PROPDMG * 1e9,
storm$PROPDMG)))
storm$CROPDMGVALUE <- ifelse(storm$CROPDMGEXP == "K",
storm$CROPDMG * 1000,
ifelse(storm$CROPDMGEXP == "M",
storm$CROPDMG * 1e6,
ifelse(storm$CROPDMGEXP == "B",
storm$CROPDMG * 1e9,
storm$CROPDMG)))
economic <- storm %>%
group_by(EVTYPE) %>%
summarise(
total_damage = sum(PROPDMGVALUE + CROPDMGVALUE,
na.rm = TRUE)
) %>%
arrange(desc(total_damage))
head(economic, 10)
## # A tibble: 10 × 2
## EVTYPE total_damage
## <chr> <dbl>
## 1 FLOOD 150319678257
## 2 HURRICANE/TYPHOON 71913712800
## 3 TORNADO 57352114049.
## 4 STORM SURGE 43323541000
## 5 HAIL 18758221521.
## 6 FLASH FLOOD 17562129167.
## 7 DROUGHT 15018672000
## 8 HURRICANE 14610229010
## 9 RIVER FLOOD 10148404500
## 10 ICE STORM 8967041360
top_economic <- head(economic, 10)
ggplot(
top_economic,
aes(
x = reorder(EVTYPE, total_damage),
y = total_damage / 1e9
)
) +
geom_col(fill = "darkred") +
coord_flip() +
labs(
title = "Top 10 Weather Events by Economic Damage",
x = "Event Type",
y = "Total Economic Damage (Billions of Dollars)"
)
The analysis showed that tornadoes caused the greatest impact on population health, resulting in the highest combined number of fatalities and injuries. Floods caused the greatest economic damage when property and crop losses were combined. These findings suggest that different weather events have different types of impacts, with tornadoes posing the greatest risk to human health and floods causing the largest financial losses.