#Synopsis We looked at weather data from the US between 1950 and 2011. We wanted to find out two things:

Which weather events hurt or kill the most people? Which weather events cause the most damage to buildings and farms? We found that tornadoes are the most dangerous for people, and floods cause the most damage to property. This information can help cities and towns prepare better for bad weather.

Data Processing

First, we need to get our tools ready:

Setup library

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)
library(tidyr)

Now, let’s get the weather data:

Download and read the data

storm_data <- read.csv("repdata_data_StormData.csv.bz2")

Let’s organize our data:

Summarize health impact by event type

health_impact <- storm_data %>%
  group_by(EVTYPE) %>%
  summarise(
    fatalities = sum(FATALITIES),
    injuries = sum(INJURIES),
    total_health_impact = fatalities + injuries
  ) %>%
  arrange(desc(total_health_impact))

Convert damage exponents

storm_data$PROPDMGEXP <- toupper(storm_data$PROPDMGEXP)
storm_data$CROPDMGEXP <- toupper(storm_data$CROPDMGEXP)

Function to convert damage values

convert_damage <- function(damage, exp) {
  multiplier <- case_when(
    exp == "K" ~ 1e3,
    exp == "M" ~ 1e6,
    exp == "B" ~ 1e9,
    TRUE ~ 1
  )
  return(damage * multiplier)
}

Calculate total economic damage

economic_impact <- storm_data %>%
  mutate(
    prop_damage = convert_damage(PROPDMG, PROPDMGEXP),
    crop_damage = convert_damage(CROPDMG, CROPDMGEXP),
    total_damage = prop_damage + crop_damage
  ) %>%
  group_by(EVTYPE) %>%
  summarise(total_damage = sum(total_damage)) %>%
  arrange(desc(total_damage))

Results

Population Health Impact

Plot top 10 most harmful events to population health

top_10_health <- head(health_impact, 10)

ggplot(top_10_health, aes(x = reorder(EVTYPE, total_health_impact), y = total_health_impact)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  coord_flip() +
  labs(
    title = "Top 10 Most Harmful Weather Events to Population Health",
    x = "Event Type",
    y = "Total Injuries and Fatalities"
  ) +
  theme_minimal()

This picture shows that tornadoes hurt and kill more people than any other type of weather. Hot weather and strong winds are also very dangerous.

Economic Impact

Plot top 10 events with greatest economic impact

top_10_economic <- head(economic_impact, 10)

ggplot(top_10_economic, aes(x = reorder(EVTYPE, total_damage), y = total_damage/1e9)) +
  geom_bar(stat = "identity", fill = "darkred") +
  coord_flip() +
  labs(
    title = "Top 10 Weather Events with Greatest Economic Impact",
    x = "Event Type",
    y = "Total Damage (Billions of Dollars)"
  ) +
  theme_minimal()

This picture shows that floods cause the most damage to buildings and farms. Hurricanes and tornadoes also cause a lot of damage. The costs are shown in billions of dollars.

In conclusion, different types of weather cause different problems. Tornadoes are most dangerous for people, while floods cost the most money in damage. This information can help towns and cities get ready for bad weather.