This report analyzes the NOAA storm database to determine which types of events are most harmful to population health and which cause the greatest economic damage. The analysis focuses on fatalities, injuries, and property and crop damage.
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.5.3
data <- read.csv("repdata_data_StormData.csv.bz2")
data2 <- data[, c("EVTYPE", "FATALITIES", "INJURIES", "PROPDMG", "CROPDMG")]
health <- aggregate(FATALITIES + INJURIES ~ EVTYPE, data = data2, sum)
economic <- aggregate(PROPDMG + CROPDMG ~ EVTYPE, data = data2, sum)
health <- health[order(-health$`FATALITIES + INJURIES`), ][1:10, ]
economic <- economic[order(-economic$`PROPDMG + CROPDMG`), ][1:10, ]
ggplot(health, aes(x=reorder(EVTYPE, -`FATALITIES + INJURIES`),
y=`FATALITIES + INJURIES`)) +
geom_bar(stat="identity") +
theme(axis.text.x = element_text(angle=45, hjust=1)) +
labs(title="Top 10 Harmful Events", x="Event Type", y="Total Harm")
ggplot(economic, aes(x=reorder(EVTYPE, -`PROPDMG + CROPDMG`),
y=`PROPDMG + CROPDMG`)) +
geom_bar(stat="identity") +
theme(axis.text.x = element_text(angle=45, hjust=1)) +
labs(title="Top 10 Economic Damage Events", x="Event Type", y="Damage")