Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern.
This project aims to explore the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database in order to discuss events that are most harmful to population health as well as those related to greatest economic consequences. This database tracks characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of any fatalities, injuries, and property damage.The events in the database start in the year 1950 and end in November 2011. the analysis revealed that across US, tornadoes result in the highest fatalities and injuries counts as well as highest property damage. However hails followed by flash floods are the top causes of crop damage across US.
library(R.utils)
## Warning: package 'R.utils' was built under R version 4.3.3
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
##
## Attaching package: 'R.oo'
## The following object is masked from 'package:R.methodsS3':
##
## throw
## The following objects are masked from 'package:methods':
##
## getClasses, getMethods
## The following objects are masked from 'package:base':
##
## attach, detach, load, save
## R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
##
## Attaching package: 'R.utils'
## The following object is masked from 'package:utils':
##
## timestamp
## The following objects are masked from 'package:base':
##
## cat, commandArgs, getOption, isOpen, nullfile, parse, warnings
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.3.3
##
## 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(tidyr)
##
## Attaching package: 'tidyr'
## The following object is masked from 'package:R.utils':
##
## extract
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
library(xtable)
URL <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
if(!file.exists("repdata_data_StormData.csv.bz2")){
download.file(URL, destfile = "repdata_data_StormData.csv.bz2")
}
if(file.exists("repdata_data_StormData.csv.bz2")){
bunzip2("repdata_data_StormData.csv.bz2", overwrite = TRUE)
}
raw.data <- read.csv("D:/r project/r project/repdata_data_StormData.csv")
names_1 <- names(raw.data)
The names of the raw data columns are STATE_, BGN_DATE, BGN_TIME, TIME_ZONE, COUNTY, COUNTYNAME, STATE, EVTYPE, BGN_RANGE, BGN_AZI, BGN_LOCATI, END_DATE, END_TIME, COUNTY_END, COUNTYENDN, END_RANGE, END_AZI, END_LOCATI, LENGTH, WIDTH, F, MAG, FATALITIES, INJURIES, PROPDMG, PROPDMGEXP, CROPDMG, CROPDMGEXP, WFO, STATEOFFIC, ZONENAMES, LATITUDE, LONGITUDE, LATITUDE_E, LONGITUDE, REMARKS, REFNUM
raw.data <- raw.data[complete.cases(raw.data),]
The data are now ready for downstream analysis
cleaned_data <- raw.data %>%
group_by(EVTYPE) %>%
summarize(
Total_Fatalities = sum(FATALITIES, na.rm = TRUE),
Total_PropDmg = sum(PROPDMG, na.rm = TRUE),
Total_CropDmg = sum(CROPDMG, na.rm = TRUE),
Total_Injuries = sum(INJURIES, na.rm = TRUE)
)
top_fatalities <- cleaned_data %>%
arrange(desc(Total_Fatalities))
top_injures <- cleaned_data %>%
arrange(desc(Total_Injuries))
top_cropdmg <- cleaned_data %>%
arrange(desc(Total_CropDmg))
top_propdmg <- cleaned_data %>%
arrange(desc(Total_PropDmg))
head(top_fatalities)
## # A tibble: 6 × 5
## EVTYPE Total_Fatalities Total_PropDmg Total_CropDmg Total_Injuries
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 TORNADO 5633 3212258. 100019. 91346
## 2 EXCESSIVE HEAT 1903 1460 494. 6525
## 3 FLASH FLOOD 978 1420125. 179200. 1777
## 4 HEAT 937 298. 663. 2100
## 5 LIGHTNING 816 603352. 3581. 5230
## 6 TSTM WIND 504 1335966. 109203. 6957
head(top_propdmg)
## # A tibble: 6 × 5
## EVTYPE Total_Fatalities Total_PropDmg Total_CropDmg Total_Injuries
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 TORNADO 5633 3212258. 100019. 91346
## 2 FLASH FLOOD 978 1420125. 179200. 1777
## 3 TSTM WIND 504 1335966. 109203. 6957
## 4 FLOOD 470 899938. 168038. 6789
## 5 THUNDERSTORM WIND 133 876844. 66791. 1488
## 6 HAIL 15 688693. 579596. 1361
from analyzing the data, the results showed that Tornadoes result in the highest fatalities with estimate count of 5633, additionally, it results in the highest injuries count and property damage with counts of 91346 and 3212258.2 respectively.
However, hails resulted in the highest crop damage among all events across US with estimate count of 579596.28.
The following plots shows the top five events that are most harmful to population health and economy.
plot_1 <- ggplot(top_fatalities[1:5, ], aes(x = reorder(EVTYPE, -Total_Fatalities), y = Total_Fatalities)) +
geom_point(stat = "identity", color = "red", size=3) +
scale_y_continuous(limits = range(top_fatalities$Total_Fatalities+200)) +
geom_text(aes(label = Total_Fatalities), vjust = -0.5, size = 3) + # Add values on top of bars
labs(x = "Event Type", y = "Total Fatalities", title = "Top five fatal events", size=10) +
theme(axis.text.x = element_text(size = 6))
plot_2 <- ggplot(top_injures[1:5, ], aes(x = reorder(EVTYPE, -Total_Injuries), y = Total_Injuries)) +
geom_point(stat = "identity", color = "skyblue", size= 3) +
geom_text(aes(label = Total_Injuries), vjust = -0.5, size = 3) + # Add values on top of bars
scale_y_continuous(limits = range(top_injures$Total_Injuries)) +
labs(x = "Event Type", y = "Total Injuries", title = "Top five injury-causing events") +
theme(axis.text.x = element_text(size = 6)) # Rotate x-axis labels for better readability
grid.arrange(plot_1, plot_2, ncol = 2)
plot_3 <- ggplot(top_cropdmg[1:5, ], aes(x = reorder(EVTYPE, -Total_CropDmg), y = Total_CropDmg)) +
geom_point(stat = "identity", color = "red") +
scale_y_continuous(limits = range(top_cropdmg$Total_CropDmg+1000)) +
geom_text(aes(label = Total_CropDmg), vjust = -0.5, size = 3) + # Add values on top of bars
labs(x = "Event Type", y = "Total crop damage", title = "Top five crop-damaging events", size=10) +
theme(axis.text.x = element_text(size = 6))
plot_4 <- ggplot(top_propdmg[1:5, ], aes(x = reorder(EVTYPE, -Total_PropDmg), y = Total_PropDmg)) +
geom_point(stat = "identity", color = "skyblue") +
geom_text(aes(label = Total_PropDmg), vjust = -0.5, size = 3) + # Add values on top of bars
labs(x = "Event Type", y = "Total Property Damage", title = "Top five property damaging events") +
theme(axis.text.x = element_text(size = 6)) # Rotate x-axis labels for better readability
grid.arrange(plot_3, plot_4, ncol = 2)