Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern. This project involves exploring the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. This database tracks characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of any fatalities, injuries, and economics damage. The events in the database start in the year 1950 and end in November 2011.

The analysis performed here exctracts from this database the total number of fatalities, injuries, and the total cost related to property and crop damages divided by event type, aiming to answer the questions:

  1. Across the United States, which types of events are most harmful with respect to population health?
  2. Across the United States, which types of events have the greatest economic consequences?

Data Processing

. Loading and viewing data

stormdata<-read.csv("C:/data scientist/repro research/week 4/StormData.csv",stringsAsFactors = F)
head(stormdata) #view data
##   STATE__           BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1       1  4/18/1950 0:00:00      130       CST     97     MOBILE    AL
## 2       1  4/18/1950 0:00:00      145       CST      3    BALDWIN    AL
## 3       1  2/20/1951 0:00:00     1600       CST     57    FAYETTE    AL
## 4       1   6/8/1951 0:00:00      900       CST     89    MADISON    AL
## 5       1 11/15/1951 0:00:00     1500       CST     43    CULLMAN    AL
## 6       1 11/15/1951 0:00:00     2000       CST     77 LAUDERDALE    AL
##    EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END
## 1 TORNADO         0                                               0
## 2 TORNADO         0                                               0
## 3 TORNADO         0                                               0
## 4 TORNADO         0                                               0
## 5 TORNADO         0                                               0
## 6 TORNADO         0                                               0
##   COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1                    0                        14   100 3   0          0
## 2                    0                         2   150 2   0          0
## 3                    0                       0.1   123 2   0          0
## 4                    0                         0   100 2   0          0
## 5                    0                         0   150 2   0          0
## 6                    0                       1.5   177 2   0          0
##   INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1       15      25          K       0                                    
## 2        0     2.5          K       0                                    
## 3        2      25          K       0                                    
## 4        2     2.5          K       0                                    
## 5        2     2.5          K       0                                    
## 6        6     2.5          K       0                                    
##   LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM X X.1 X.2 X.3
## 1     3040      8812       3051       8806              1              
## 2     3042      8755          0          0              2              
## 3     3340      8742          0          0              3              
## 4     3458      8626          0          0              4              
## 5     3412      8642          0          0              5              
## 6     3450      8748          0          0              6              
##   X.4 X.5 X.6 X.7 X.8 X.9 X.10 X.11 X.12 X.13 X.14 X.15 X.16
## 1                                                         NA
## 2                                                         NA
## 3                                                         NA
## 4                                                         NA
## 5                                                         NA
## 6                                                         NA

Results

  1. Preparation for the first question
stormdata$FATALITIES<-as.numeric(stormdata$FATALITIES, na.strings = T)
## Warning: 强制改变过程中产生了NA
aggstorm_f<- aggregate(FATALITIES ~ EVTYPE , stormdata,sum)
stormdata$INJURIES<-as.numeric(stormdata$INJURIES, na.strings = T)
## Warning: 强制改变过程中产生了NA
aggstorm_i<- aggregate(INJURIES ~ EVTYPE , stormdata, sum)
aggstorm<-merge(aggstorm_f,aggstorm_i,by = "EVTYPE")
aggstorm$fori<-sum(aggstorm$FATALITIES,aggstorm$INJURIES)
aggstorm$fori<- rowSums(aggstorm[,2:3]) # fori means fatalities or injuries
data_f<-aggstorm_f[order(aggstorm_f$FATALITIES,decreasing = T),]
barplot(data_f[1:5,]$FATALITIES,xlab = "Event Type", ylab = "Total Number of Fatalities",names.arg = data_f[1:5,]$EVTYPE,main = "Total Fatatilities Caused by Different Event Types") 

data_i<-aggstorm_i[order(aggstorm_i$INJURIES,decreasing = T),]
barplot(data_i[1:5,]$INJURIES,xlab = "Event Type", ylab = "Total Number of Injuries",names.arg = data_i[1:5,]$EVTYPE,main = "Total Injuries Caused by Different Event Types") 

data_T<-aggstorm[order(aggstorm$fori,decreasing = T),]
barplot(data_T[1:5,]$fori,xlab = "Event Type", ylab = "Total Number of FATATILITIES OR Injuries",names.arg = data_T[1:5,]$EVTYPE,main = "Total Injuries Caused by Different Event Types")

So we could see that the most harmful influence to population health is caused by Tornado

  1. Preparation for the second question

we have to 1) adjust the measurement unit of influence 2) conbine the influence

damage_amount <- function(amount, magnitude)
{
  return_amount <- 0
  if (toupper(magnitude)[1]=="K")
  {
    return_amount <- amount * 1000
    }
  if (toupper(magnitude)[1]=="M")
  {
    return_amount <- amount * 1000000
  }
  if (toupper(magnitude)[1]=="B")
  {
    return_amount <- amount * 1000000000
  }
  return(return_amount)
}
damgdata<-stormdata[,c(8,25,26,27,28)]
damgdata$PROPDMG <- as.numeric(damgdata$PROPDMG, na.strings = T)
## Warning: 强制改变过程中产生了NA
damgdata$CROPDMG <- as.numeric(damgdata$CROPDMG, na.strings = T)
## Warning: 强制改变过程中产生了NA
damgdata$damgamout <-((mapply(damage_amount, damgdata$PROPDMG, damgdata$PROPDMGEXP)) +(mapply(damage_amount, damgdata$CROPDMG, damgdata$CROPDMGEXP))) # combine the 2 damages
aggstorm_damg <- aggregate(damgamout ~ EVTYPE,damgdata,sum) # sum up the damage amout by events type
data_d <- aggstorm_damg[order(aggstorm_damg$damgamout,decreasing = T),]
barplot(data_d[1:5,]$damgamout,xlab = "Event Type",ylab = "Total Damages caused in Property or crop",main = "Total Economic Consequences Caused by Different Event Types",names.arg = data_d[1:5,]$EVTYPE)