Synopsis:

This analysis aims to explore severe weather events in the United States using the NOAA Storm Database. It identifies the types of events that are most harmful to population health and those that have the greatest economic consequences. The results of this analysis are intended to assist municipal managers in understanding the impacts of various weather events.

Data Processing Section

The raw data for this analysis comes from the NOAA Storm Database, which contains information on various severe weather events in the United States. The data includes fields such as event type (EVTYPE), fatalities, injuries, property damage (PROPDMG), and crop damage (CROPDMG), along with other related information.

Loading the Data

We begin by loading the dataset into R, ensuring that we can examine the structure and preprocess it for analysis.

# Load necessary libraries
library(dplyr)
## 
## Присоединяю пакет: 'dplyr'
## Следующие объекты скрыты от 'package:stats':
## 
##     filter, lag
## Следующие объекты скрыты от 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)

# Load the dataset
storm_data <- read.csv("repdata_data_StormData.csv")

# Check the structure of the data
str(storm_data)
## 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : chr  "4/18/1950 0:00:00" "4/18/1950 0:00:00" "2/20/1951 0:00:00" "6/8/1951 0:00:00" ...
##  $ BGN_TIME  : chr  "0130" "0145" "1600" "0900" ...
##  $ TIME_ZONE : chr  "CST" "CST" "CST" "CST" ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: chr  "MOBILE" "BALDWIN" "FAYETTE" "MADISON" ...
##  $ STATE     : chr  "AL" "AL" "AL" "AL" ...
##  $ EVTYPE    : chr  "TORNADO" "TORNADO" "TORNADO" "TORNADO" ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : chr  "" "" "" "" ...
##  $ BGN_LOCATI: chr  "" "" "" "" ...
##  $ END_DATE  : chr  "" "" "" "" ...
##  $ END_TIME  : chr  "" "" "" "" ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : chr  "" "" "" "" ...
##  $ END_LOCATI: chr  "" "" "" "" ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: chr  "K" "K" "K" "K" ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: chr  "" "" "" "" ...
##  $ WFO       : chr  "" "" "" "" ...
##  $ STATEOFFIC: chr  "" "" "" "" ...
##  $ ZONENAMES : chr  "" "" "" "" ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : chr  "" "" "" "" ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...

Data Cleaning

To ensure the data is suitable for analysis, we perform the following preprocessing steps:

  1. Convert date fields to Date type.

  2. Filter out rows with missing values for key variables like event type, fatalities, injuries, and damage values.

  3. Handle the PROPDMGEXP and CROPDMGEXP columns, which represent the exponents for property and crop damage (e.g., “K” for thousand, “M” for million).

# Clean the data (convert date, filter missing values)
storm_data <- storm_data %>%
  mutate(BGN_DATE = as.Date(BGN_DATE, format="%m/%d/%Y")) %>%
  filter(!is.na(EVTYPE), !is.na(FATALITIES), !is.na(INJURIES), !is.na(PROPDMG), !is.na(CROPDMG))

# Convert PROPDMGEXP and CROPDMGEXP to proper numeric values
storm_data$PROPDMGEXP <- as.character(storm_data$PROPDMGEXP)
storm_data$CROPDMGEXP <- as.character(storm_data$CROPDMGEXP)

# Handle exponential values in property damage and crop damage
storm_data <- storm_data %>%
  mutate(PROPDMG = case_when(
    PROPDMGEXP == "K" ~ PROPDMG * 1000,
    PROPDMGEXP == "M" ~ PROPDMG * 1e6,
    PROPDMGEXP == "B" ~ PROPDMG * 1e9,
    TRUE ~ PROPDMG
  ),
  CROPDMG = case_when(
    CROPDMGEXP == "K" ~ CROPDMG * 1000,
    CROPDMGEXP == "M" ~ CROPDMG * 1e6,
    CROPDMGEXP == "B" ~ CROPDMG * 1e9,
    TRUE ~ CROPDMG
  ))

# Summarize the cleaned data
summary(storm_data)
##     STATE__        BGN_DATE            BGN_TIME          TIME_ZONE        
##  Min.   : 1.0   Min.   :1950-01-03   Length:902297      Length:902297     
##  1st Qu.:19.0   1st Qu.:1995-04-20   Class :character   Class :character  
##  Median :30.0   Median :2002-03-18   Mode  :character   Mode  :character  
##  Mean   :31.2   Mean   :1998-12-27                                        
##  3rd Qu.:45.0   3rd Qu.:2007-07-28                                        
##  Max.   :95.0   Max.   :2011-11-30                                        
##                                                                           
##      COUNTY       COUNTYNAME           STATE              EVTYPE         
##  Min.   :  0.0   Length:902297      Length:902297      Length:902297     
##  1st Qu.: 31.0   Class :character   Class :character   Class :character  
##  Median : 75.0   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :100.6                                                           
##  3rd Qu.:131.0                                                           
##  Max.   :873.0                                                           
##                                                                          
##    BGN_RANGE          BGN_AZI           BGN_LOCATI          END_DATE        
##  Min.   :   0.000   Length:902297      Length:902297      Length:902297     
##  1st Qu.:   0.000   Class :character   Class :character   Class :character  
##  Median :   0.000   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :   1.484                                                           
##  3rd Qu.:   1.000                                                           
##  Max.   :3749.000                                                           
##                                                                             
##    END_TIME           COUNTY_END COUNTYENDN       END_RANGE       
##  Length:902297      Min.   :0    Mode:logical   Min.   :  0.0000  
##  Class :character   1st Qu.:0    NA's:902297    1st Qu.:  0.0000  
##  Mode  :character   Median :0                   Median :  0.0000  
##                     Mean   :0                   Mean   :  0.9862  
##                     3rd Qu.:0                   3rd Qu.:  0.0000  
##                     Max.   :0                   Max.   :925.0000  
##                                                                   
##    END_AZI           END_LOCATI            LENGTH              WIDTH         
##  Length:902297      Length:902297      Min.   :   0.0000   Min.   :   0.000  
##  Class :character   Class :character   1st Qu.:   0.0000   1st Qu.:   0.000  
##  Mode  :character   Mode  :character   Median :   0.0000   Median :   0.000  
##                                        Mean   :   0.2301   Mean   :   7.503  
##                                        3rd Qu.:   0.0000   3rd Qu.:   0.000  
##                                        Max.   :2315.0000   Max.   :4400.000  
##                                                                              
##        F               MAG            FATALITIES          INJURIES        
##  Min.   :0.0      Min.   :    0.0   Min.   :  0.0000   Min.   :   0.0000  
##  1st Qu.:0.0      1st Qu.:    0.0   1st Qu.:  0.0000   1st Qu.:   0.0000  
##  Median :1.0      Median :   50.0   Median :  0.0000   Median :   0.0000  
##  Mean   :0.9      Mean   :   46.9   Mean   :  0.0168   Mean   :   0.1557  
##  3rd Qu.:1.0      3rd Qu.:   75.0   3rd Qu.:  0.0000   3rd Qu.:   0.0000  
##  Max.   :5.0      Max.   :22000.0   Max.   :583.0000   Max.   :1700.0000  
##  NA's   :843563                                                           
##     PROPDMG           PROPDMGEXP           CROPDMG           CROPDMGEXP       
##  Min.   :0.000e+00   Length:902297      Min.   :0.000e+00   Length:902297     
##  1st Qu.:0.000e+00   Class :character   1st Qu.:0.000e+00   Class :character  
##  Median :0.000e+00   Mode  :character   Median :0.000e+00   Mode  :character  
##  Mean   :4.735e+05                      Mean   :5.441e+04                     
##  3rd Qu.:5.000e+02                      3rd Qu.:0.000e+00                     
##  Max.   :1.150e+11                      Max.   :5.000e+09                     
##                                                                               
##      WFO             STATEOFFIC         ZONENAMES            LATITUDE   
##  Length:902297      Length:902297      Length:902297      Min.   :   0  
##  Class :character   Class :character   Class :character   1st Qu.:2802  
##  Mode  :character   Mode  :character   Mode  :character   Median :3540  
##                                                           Mean   :2875  
##                                                           3rd Qu.:4019  
##                                                           Max.   :9706  
##                                                           NA's   :47    
##    LONGITUDE        LATITUDE_E     LONGITUDE_       REMARKS         
##  Min.   :-14451   Min.   :   0   Min.   :-14455   Length:902297     
##  1st Qu.:  7247   1st Qu.:   0   1st Qu.:     0   Class :character  
##  Median :  8707   Median :   0   Median :     0   Mode  :character  
##  Mean   :  6940   Mean   :1452   Mean   :  3509                     
##  3rd Qu.:  9605   3rd Qu.:3549   3rd Qu.:  8735                     
##  Max.   : 17124   Max.   :9706   Max.   :106220                     
##                   NA's   :40                                        
##      REFNUM      
##  Min.   :     1  
##  1st Qu.:225575  
##  Median :451149  
##  Mean   :451149  
##  3rd Qu.:676723  
##  Max.   :902297  
## 

Results

Most Harmful Events with Respect to Population Health

The analysis of health impacts focuses on the total number of fatalities and injuries associated with each type of event. We will group the data by event type and summarize the total fatalities and injuries.

# Summarize total fatalities and injuries by event type
health_impact <- storm_data %>%
  group_by(EVTYPE) %>%
  summarize(FATALITIES = sum(FATALITIES), INJURIES = sum(INJURIES)) %>%
  arrange(desc(FATALITIES + INJURIES))

# Select top 10 most harmful events
health_impact_top <- head(health_impact, 10)

# Plot the most harmful events in terms of fatalities and injuries
ggplot(health_impact_top, aes(x=reorder(EVTYPE, -(FATALITIES + INJURIES)), y=FATALITIES + INJURIES)) +
  geom_bar(stat="identity") +
  coord_flip() +
  labs(title="Top 10 Most Harmful Events in Terms of Population Health", x="Event Type", y="Total Impact (Fatalities + Injuries)")

Events with Greatest Economic Consequences

For economic consequences, we calculate the total property and crop damage by event type and visualize the top contributors to economic loss.

# Summarize total damage by event type
economic_impact <- storm_data %>%
  group_by(EVTYPE) %>%
  summarize(TOTAL_DAMAGE = sum(PROPDMG + CROPDMG)) %>%
  arrange(desc(TOTAL_DAMAGE))

# Select top 10 events with the greatest economic consequences
economic_impact_top <- head(economic_impact, 10)

# Plot the most economically damaging events
ggplot(economic_impact_top, aes(x=reorder(EVTYPE, -TOTAL_DAMAGE), y=TOTAL_DAMAGE)) +
  geom_bar(stat="identity") +
  coord_flip() +
  labs(title="Top 10 Events with Greatest Economic Consequences", x="Event Type", y="Total Damage ($)")

Conclusion

The analysis of the NOAA Storm Database reveals the following:

*Most Harmful Events to Population Health: Tornadoes and floods are the most damaging events in terms of fatalities and injuries across the United States.

*Events with the Greatest Economic Consequences: Hurricanes and floods are the primary contributors to property and crop damage.

These findings provide valuable insights that can help municipalities and government agencies prioritize resources for preparedness and mitigation efforts.

Additional Notes

Figures: There are two key figures in the Results section: one showing the health impact of different events and another showing the economic impact.

Code: All necessary code for data processing and analysis is included, with echo = TRUE for reproducibility.

R Markdown Output: The document will be compiled into an HTML report and uploaded to RPubs.