The following analyzes the U.S. National Oceanic and Atmospheric Administration’s storm database to find which weather events are most harmful with respect to population health and which events have the greatest economic impact.

Data Processing

library(dplyr)

#The storm data file must be in your working directory
readFile <- read.csv("repdata%2Fdata%2FStormData.csv.bz2")

#Establish common names of some event types with high impact to overall results
stormdata <- mutate(readFile, EVTYPE=gsub("TSTM WIND|THUNDERSTORM WINDS|THUNDERSTORM WIND", 
                                          "T-STORM WIND", readFile$EVTYPE))
stormdata <- mutate(stormdata, EVTYPE=gsub("HURRICANE|HURRICANE/TYPHOON|Hurricane Edouard|
                                           HURRICANE/TYPHOON-GENERATED SWELLS|HURRICANE/TYPHOON EMILY|
                                           HURRICANE/TYPHOON ERIN|HURRICANE/TYPHOON FELIX|
                                           HURRICANE/TYPHOON GORDON|HURRICANE/TYPHOON OPAL|
                                           HURRICANE/TYPHOON OPAL/HIGH WINDS", 
                                           "HURRICANE/TYPHOON", stormdata$EVTYPE))

#Calculating total Fatalities & Injuries grouped by Event Type
FtlInj <- mutate(stormdata, Ftl_Inj = FATALITIES + INJURIES)

Pop_Health <- FtlInj %>%
                 group_by(EVTYPE) %>%
                 summarize(HEALTH=sum(Ftl_Inj)) %>%
                 arrange(desc(HEALTH)) %>%
                 as.data.frame()

#Calculating Property & Crop Damage by Event Type
stormdata <- mutate(stormdata, Property_Damage = if_else(PROPDMGEXP=="K", PROPDMG*10^3,
                                                 if_else(PROPDMGEXP=="M", PROPDMG*10^6,
                                                 if_else(PROPDMGEXP=="B", PROPDMG*10^9, PROPDMG))))

stormdata <- mutate(stormdata, Crop_Damage = if_else(CROPDMGEXP=="K", CROPDMG*10^3,
                                             if_else(CROPDMGEXP=="M", CROPDMG*10^6,
                                             if_else(CROPDMGEXP=="B", CROPDMG*10^9, CROPDMG))))

stormdata <- mutate(stormdata, Total_Damage = Property_Damage + Crop_Damage)

TotalDamage <- stormdata %>%
                group_by(EVTYPE) %>%
                summarize(Total_Damage=sum(Total_Damage)/10^9) %>%
                arrange(desc(Total_Damage)) %>%
                as.data.frame()

Results

#Fatalities & Injuries
par(mar=c(8,6,2,2))
barplot(Pop_Health[1:10,2], names.arg = Pop_Health[1:10,1], 
        las = 2, cex.names = 0.7, xlab = "", ylab = "", 
        main = "Number of Fatalities & Injuries by Event Type (Top 10)") 
mtext("Event Type", side = 1, line = 5.5)
mtext("Number of Fatalities & Injuries", side = 2, line = 4)


Among weather related events in the U.S., tornados had the greatest health impact, causing fatalities & injures of over 90,000.

#Property & Crop Damage
par(mar=c(8,6,2,2))
barplot(TotalDamage[1:10,2], names.arg = TotalDamage[1:10,1], 
        las = 2, cex.names = 0.7, xlab = "", ylab = "", 
        main = "Total Property & Crop Damage by Event Type in the U.S. (Top 10)") 
mtext("Event Type", side = 1, line = 5.5)
mtext("Property & Crop Damage (Billions)", side = 2, line = 4)


Among weather related events in the U.S., flooding has the greatest economic consequences, causing property & crop damage of over $150 Billion.