This analysis explores data from the NOAA Storm Database to examine the impact of severe weather events in the United States. The focus is on identifying which event types are most harmful to population health and which cause the greatest economic damage. Population health impacts are measured using fatalities and injuries, while economic consequences are measured using property and crop damage. The analysis uses data from 1950 to 2011 and summarizes impacts by event type. Results are presented using summary tables and plots to help prioritize preparedness and response efforts. ## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
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 <- read.csv("repdata_data_StormData.csv.bz2")
storm <- storm %>%
select(EVTYPE, FATALITIES, INJURIES,
PROPDMG, PROPDMGEXP,
CROPDMG, CROPDMGEXP)
convert_exp <- function(x) {
ifelse(x == "K", 1e3,
ifelse(x == "M", 1e6,
ifelse(x == "B", 1e9, 1)))
}
storm$PROPDMG <- storm$PROPDMG * convert_exp(storm$PROPDMGEXP)
storm$CROPDMG <- storm$CROPDMG * convert_exp(storm$CROPDMGEXP)
##result
health <- storm %>%
group_by(EVTYPE) %>%
summarise(
Fatalities = sum(FATALITIES),
Injuries = sum(INJURIES)
) %>%
mutate(Total = Fatalities + Injuries) %>%
arrange(desc(Total)) %>%
slice(1:10)
ggplot(health, aes(x=reorder(EVTYPE, Total), y=Total)) +
geom_bar(stat="identity", fill="red") +
coord_flip() +
labs(title="Top 10 Events Harmful to Population Health",
x="Event Type",
y="Fatalities + Injuries")
economic <- storm %>%
group_by(EVTYPE) %>%
summarise(
Damage = sum(PROPDMG + CROPDMG)
) %>%
arrange(desc(Damage)) %>%
slice(1:10)
ggplot(economic, aes(x=reorder(EVTYPE, Damage), y=Damage)) +
geom_bar(stat="identity", fill="blue") +
coord_flip() +
labs(title="Top 10 Events Causing Economic Damage",
x="Event Type",
y="Total Damage (USD)")