SYNOPSIS

Below is an analysis of the data from

To preprocess the data values in the FATALITIES, INJURIES, PROPDMG, and CROPDMG are transformed from the character type they were automatically read as into numeric format. To analyze the data it was grouped by type (EVTYPE). This allowed the summation of injuries and fatalities for each type of event to be determined in the U.S. from 1950-2011. Tornadoes harmed humans the most. This was also done for damage in dollars where floods were found to have caused the most property and farm damage in total.

DATA PREPROCESSING

The preprocessing is reading the table from the csv file ‘repdata_data_StormData.csv’ and changing the columns FATALITIES, INJURIES, PROPDMG, and CROPDMG into numeric values to sum them.

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_data <- read.csv2('repdata_data_StormData.csv.bz2', sep=',', header = TRUE)
# so the numbers representing human harm are numeric instead of a character
storm_data$FATALITIES <- as.numeric(storm_data$FATALITIES)
storm_data$INJURIES <- as.numeric(storm_data$INJURIES)
# so the numbers representing damage are numeric instead of a character
storm_data$PROPDMG <- as.numeric(storm_data$PROPDMG)
storm_data$CROPDMG <- as.numeric(storm_data$CROPDMG)

RESULTS

harmful_sum <- storm_data %>%
    group_by(EVTYPE) %>%
    summarise(INJURIES = sum(INJURIES, na.rm = TRUE),
              FATALITIES = sum(FATALITIES, na.rm = TRUE))

head(harmful_sum[order(-harmful_sum$INJURIES), ])
## # A tibble: 6 × 3
##   EVTYPE         INJURIES FATALITIES
##   <chr>             <dbl>      <dbl>
## 1 TORNADO           91346       5633
## 2 TSTM WIND          6957        504
## 3 FLOOD              6789        470
## 4 EXCESSIVE HEAT     6525       1903
## 5 LIGHTNING          5230        816
## 6 HEAT               2100        937
head(harmful_sum[order(-harmful_sum$FATALITIES), ])
## # A tibble: 6 × 3
##   EVTYPE         INJURIES FATALITIES
##   <chr>             <dbl>      <dbl>
## 1 TORNADO           91346       5633
## 2 EXCESSIVE HEAT     6525       1903
## 3 FLASH FLOOD        1777        978
## 4 HEAT               2100        937
## 5 LIGHTNING          5230        816
## 6 TSTM WIND          6957        504
most_inj <- harmful_sum %>%
    slice_max(INJURIES, with_ties = FALSE)
most_fat <- harmful_sum %>%
    slice_max(FATALITIES, with_ties = FALSE)
worst_ev <- most_inj$EVTYPE[[1]]
worst_inj <- most_inj$INJURIES[[1]]
worst_fat <- most_fat$FATALITIES[[1]]

Across the United States, TORNADO is the worst event type for population health with 91346 injuries and 5633 fatalities. The 6 worst event types in terms of injuries and fatalities can be seen above. They are all natural disasters, involve heat, or is lightning.

storm_damage <- storm_data[, c('EVTYPE', 'PROPDMG', 'PROPDMGEXP', 'CROPDMG',
                               'CROPDMGEXP')]
# list of exponents for PROPDMGEXP and CROPDMG.  Unknown exponents given 0 due
# to lacking injuries and deaths indicating at worst they are insignificant
# towards determining the most economically damaging event type.
exp_to_num = c("K"=1e3, "M"=1e6,  "B"=1e9, "m"=1e6, "+"=1, "0"=0, 'k'=1e3,
                  "5"=0, "6"=0, "?"=0, "4"=0, "2"=0, "3"=0, "h"=0, "7"=0, "H"=0,
                  "-"=0, "1"=0, "8"=0, '-1'=0)
# gets in numeric form total property and crop damage of rows
storm_damage$PROPDMGEXP[storm_damage$PROPDMGEXP == ''] <- '-1'
storm_damage$PROPDMGTOTAL <- as.numeric(exp_to_num[storm_damage$PROPDMGEXP]) *
    storm_damage$PROPDMG
storm_damage$CROPDMGEXP[storm_damage$CROPDMGEXP == ''] <- '-1'
storm_damage$CROPDMGTOTAL <- as.numeric(exp_to_num[storm_damage$CROPDMGEXP])# * storm_damage$CROPDMG
# total damage
storm_damage$TOTALDMG <- storm_damage$PROPDMGTOTAL + storm_damage$CROPDMGTOTAL
# groups damage cost by EVTYPE. Gets total cost and cost from crops and property
damage_type <- storm_damage %>%
    group_by(EVTYPE) %>%
    summarise(TOTAL=sum(TOTALDMG), PROP=sum(PROPDMGTOTAL),
              CROP=sum(CROPDMGTOTAL))

# to order by total cost of events over time
damage_type <- damage_type[order(-damage_type$TOTAL), ]
ggplot(damage_type[15:1,], aes(x=factor(EVTYPE, levels = EVTYPE), y=TOTAL)) +
    geom_col(stat = 'identity') + coord_flip() + 
    labs(title = 'U.S. Total $ Amount Damage by 15 Most Damaging Event Type', x='Cause of Damage', y='Damage Amount ($)')

Based on the barplot above the most damaging events by dollar amount are floods. Then it is hurricanes and tornadoes. In general the most costly events involve water then extreme wind. Unfortunately, without knowing a location to advice what to focus on would be impossible as these events, like tornadoes, can be very regional.