This document its aimed to analyse U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database to help government or municipal manager who might be responsible for preparing for severe weather events and will need to prioritize resources for different types of events.
We will find most human harmful and economic damage for type of event
library(ggplot2)
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
if(!file.exists("./stormData.csv.bz2")){
download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2", destfile = "./stormData.csv.bz2")
}
## data
stormData <- read.csv("stormData.csv.bz2")
# Convert letters in numbers to find economic damage
stormData$PROPDMGEXP <- as.character(stormData$PROPDMGEXP)
stormData$PROPDMGEXP[stormData$PROPDMGEXP == "K"] <- 1000
stormData$PROPDMGEXP[stormData$PROPDMGEXP == "M"] <- 1e+06
stormData$PROPDMGEXP[stormData$PROPDMGEXP == "B"] <- 1e+09
stormData$PROPDMGEXP <- as.numeric(stormData$PROPDMGEXP)
## Warning: NAs introduced by coercion
stormData$CROPDMGEXP <- as.character(stormData$CROPDMGEXP)
stormData$CROPDMGEXP[stormData$CROPDMGEXP == "K"] <- 1000
stormData$CROPDMGEXP[stormData$CROPDMGEXP == "M"] <- 1e+06
stormData$CROPDMGEXP[stormData$CROPDMGEXP == "B"] <- 1e+09
stormData$CROPDMGEXP <- as.numeric(stormData$CROPDMGEXP)
## Warning: NAs introduced by coercion
## We will use dplyr
stormTable <- tbl_df(stormData)
## group data by event type
humanDamage <-stormTable %>% select(EVTYPE,FATALITIES,INJURIES) %>% filter (INJURIES > 0) %>%group_by(EVTYPE)
summarize(humanDamage, TOTAL_FATALITIES =sum(FATALITIES), TOTAL_INJURIES = sum(INJURIES)) %>% arrange(desc(TOTAL_FATALITIES))
## Source: local data frame [158 x 3]
##
## EVTYPE TOTAL_FATALITIES TOTAL_INJURIES
## (fctr) (dbl) (dbl)
## 1 TORNADO 5227 91346
## 2 EXCESSIVE HEAT 402 6525
## 3 LIGHTNING 283 5230
## 4 TSTM WIND 199 6957
## 5 FLASH FLOOD 171 1777
## 6 FLOOD 104 6789
## 7 HIGH WIND 102 1137
## 8 WINTER STORM 85 1321
## 9 HEAT 73 2100
## 10 WILDFIRE 55 911
## .. ... ... ...
As we can see the most harmful human event is TORNADOS (They ara at top of previouse list)
Let’s see where dose the Tornados are concetrated.
tornados <- select(stormTable,EVTYPE,LATITUDE,LONGITUDE,INJURIES) %>% filter(EVTYPE == 'TORNADO', LATITUDE !=0,LONGITUDE !=0)
plot(-tornados$LONGITUDE,tornados$LATITUDE,col= rgb(0,0,0,0.1) ,main = "TORNADO AREAS")
On the east part of US there are more tornados
## group data by event type
economicDamage <-stormTable %>% select(EVTYPE,PROPDMGEXP,CROPDMGEXP) %>% filter (!is.na(PROPDMGEXP),!is.na(CROPDMGEXP)) %>%group_by(EVTYPE)
economicDamage <- mutate(economicDamage,TOTAL_ECONOMIC_DAMAGE = PROPDMGEXP+CROPDMGEXP)
summarize(economicDamage, TOTAL_DAMAGE =sum(TOTAL_ECONOMIC_DAMAGE)) %>% arrange(desc(TOTAL_DAMAGE))
## Source: local data frame [124 x 2]
##
## EVTYPE TOTAL_DAMAGE
## (fctr) (dbl)
## 1 HURRICANE/TYPHOON 7042017000
## 2 FLOOD 5267850000
## 3 TORNADO 3891885000
## 4 HURRICANE 3083050000
## 5 DROUGHT 2069731000
## 6 RIVER FLOOD 2010020000
## 7 HAIL 1937123005
## 8 FLASH FLOOD 1892396005
## 9 WILDFIRE 1117451000
## 10 ICE STORM 1070851000
## .. ... ...
As we see at the top of list HURRICANE/TYPHOON are the more economic damage event
TORNADOS are the most dangerous events for humans counting FATALITIES and INJURIES. HURRICANE/TYPHOON are the most economic damage events