The analysis of the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database reveals critical insights into severe weather events. By examining the data from 1950 to 2011, we aimed to identify the types of events that are most harmful to population health and have the greatest economic consequences. Our analysis focused on total fatalities, injuries, and property damage for each event type (EVTYPE).
Set the URL for the data file
url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(url, destfile = "StormData.csv.bz2")
storm_data <- read.csv(bzfile("StormData.csv.bz2"))
str(storm_data)
library(dplyr)
storm_data_clean <- storm_data %>% filter(!is.na(EVTYPE) & !is.na(FATALITIES) & !is.na(INJURIES) & !is.na(PROPDMG)) %>% mutate(PROPDMG = ifelse(grepl("K", PROPDMG, fixed = TRUE), as.numeric(sub("K", "", PROPDMG)) * 1000, ifelse(grepl("M", PROPDMG, fixed = TRUE), as.numeric(sub("M", "", PROPDMG)) * 1000000, as.numeric(PROPDMG))))
events_population_health <- storm_data_clean %>% group_by(EVTYPE) %>% summarise(total_fatalities = sum(FATALITIES), total_injuries = sum(INJURIES)) %>% mutate(total_health_impact = total_fatalities + total_injuries) %>% arrange(desc(total_health_impact))
events_economic_consequences <- storm_data_clean %>% group_by(EVTYPE) %>% summarise(total_property_damage = sum(PROPDMG)) %>% arrange(desc(total_property_damage))
events_population_health events_economic_consequences
library(ggplot2)
ggplot(head(events_population_health, 10), aes(x = reorder(EVTYPE, total_health_impact), y = total_health_impact)) + geom_bar(stat = "identity", fill = "skyblue") + labs(title = "Most Harmful Events with Respect to Population Health", x = "Event Type", y = "Total Health Impact") + theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))
ggplot(head(events_economic_consequences, 10), aes(x = reorder(EVTYPE, total_property_damage), y = total_property_damage)) + geom_bar(stat = "identity", fill = "lightgreen") + labs(title = "Events with Greatest Economic Consequences", x = "Event Type", y = "Total Property Damage") + theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))
storm_data_clean <- storm_data %>% filter(!is.na(EVTYPE) & !is.na(FATALITIES) & !is.na(INJURIES) & !is.na(PROPDMG) & !is.na(CROPDMG)) %>% mutate(PROPDMG = ifelse(grepl("K", PROPDMG, fixed = TRUE), as.numeric(sub("K", "", PROPDMG)) * 1000, ifelse(grepl("M", PROPDMG, fixed = TRUE), as.numeric(sub("M", "", PROPDMG)) * 1000000, as.numeric(PROPDMG))), CROPDMG = ifelse(grepl("K", CROPDMG, fixed = TRUE), as.numeric(sub("K", "", CROPDMG)) * 1000, ifelse(grepl("M", CROPDMG, fixed = TRUE), as.numeric(sub("M", "", CROPDMG)) * 1000000, as.numeric(CROPDMG))))
events_crop_damage <- storm_data_clean %>% group_by(EVTYPE) %>% summarise(total_crop_damage = sum(CROPDMG)) %>% arrange(desc(total_crop_damage))
ggplot(head(events_crop_damage, 10), aes(x = reorder(EVTYPE, total_crop_damage), y = total_crop_damage)) + geom_bar(stat = "identity", fill = "coral") + labs(title = "Events with the Next in Line Size of Economic Consequences (Crop Damage)", x = "Event Type", y = "Total Crop Damage") + theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))
As we can see crop is the next in line for major economic damage.
From the Storm Data it is clearly appear that Tornado has the worst impact in both health and economic consequences. Interestingly the most damaging weather event to crop is Hail second by Flash Flood and Flood.