Synopsis:

The goal of this analysis to answer the following two 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?

For our analysis, we take the raw data from NOAA Storm database, and use the event types as defined in the data set (i.e., without any additional mapping)

Our Analysis finds that Tornado’s are the most harmful natural events with respect to human health, and Floods are the most harmful an from economic loss perspective.

Data Processing:

download and read the source data

    #download the data
    sourceURL = "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
    destFile = "StormData.bz2"
    download.file(sourceURL, destFile, method = "libcurl", quiet = FALSE)
    
    #read the file
    srcData <- read.csv(bzfile(destFile))
    #head(srcData)

analyse the leading causes of population damage

    #add a variable 'HumanHarm' to data set that combines fatalities and injuries
    srcData$HumanHarm <- srcData$FATALITIES + srcData$INJURIES
    #groupby and sum 'HumanHarm' based on the EVTYPE
    aggSrc_HumanHarm <- aggregate(HumanHarm ~ EVTYPE, srcData, sum)
    #sort in descending order
    aggSrc_HumanHarm_sorted <- aggSrc_HumanHarm[order(-aggSrc_HumanHarm$HumanHarm),]

analyse the leading cause of economic damage

    #get the unique levels present in propdmgexp
    levels(srcData$PROPDMGEXP)
##  [1] ""  "-" "?" "+" "0" "1" "2" "3" "4" "5" "6" "7" "8" "B" "h" "H" "K"
## [18] "m" "M"
    # we notice that there are levels with '?', 'h', & 'H' which are not documented
    #let's see the data for 'h', 'H'
    subset(srcData, PROPDMGEXP %in% c('H','h'), select = c(REMARKS) )
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        REMARKS
## 209285                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Wind damage reported at Parks Rd. and U.S. Highway 27.  Trees downed and window of a home blown out. 
## 216476                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Thunderstorm winds downed a tree in Loomis and blew down large tree limbs at Hazard.  Just west of Loomis, thunderstorm winds damaged a grain bin, a barn and another outbuilding and also flipped over a hay trailer.  Heavy rain and small hail combined with the wind to damage the corn crop. 
## 232397                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   A line of severe thunderstorms with a "bow echo" appearance moved swiftly through the Upstate during the morning hours.  Highest winds with the bow were around the Georgia border in Oconee County and one small tornado was generated west of Fair Play.  Large trees were uprooted and pines were snapped by winds about 85 knots along a path 30 yards wide and one mile long.  Gust front winds in the same area accounted for some damage.  A roof of an addition to a mobile home was removed in Walhalla and trees fell in many locations.   The wet ground contributed to some of the tree damage.  In Clemson a tree fell through a residence.  Other trees brought down power lines across the area and power was out to several thousand customers well into the evening.  In Simpsonville tree limbs were punched through the roof of a residence, the limbs were carried for some distance since there was no trees near the house.  Power outages were quite widespread across western parts of Greenville County although Donaldson Center Air Park only recorded gusts to 41 knots. 
## 232398 A strong cold front moving through the area generated high winds in the mountainous section of Greenville County downing a number of trees and power lines.  Power remained out until the next morning in some areas.  A line of thunderstorms developed along the front.  A very small tornado (possibly a "gustnado") was spotted by air traffic controllers six miles southeast of the Greenville Downtown Airport.  A weak tornado touched down in a wooded area with only tree damage reported.  Some siding was blown off a house in Taylors and significant thunderstorm winds occurred with the same part of the line at Lake Robinson north of Greer.  A spotter reported wind gusts to 80 mph with a number of trees downed.  Weaker wind damage was reported around Landrum where a few trees were downed and a railroad sign was broken off. A stronger tornado (strong F0/weak F1) was generated southwest of Greenwood from a weakly rotating thunderstorm.  The tornado touched down along Highway 10 destroying one mobile home and damaging several others - along with some homes.  The tornado lifted after a one-mile track otherwise the storm could have moved near downtown Greenwood.  The tornado track was almost due north while the parent thunderstorm moved northeast.  The thunderstorm rapidly collapsed producing strong damaging winds in an area northeast of town - from near Coronaca over to Lake Greenwood.  A couple of carports were torn from houses, a number of trees were downed, and power lines were taken down.  A home under construction was severely damaged at the lake.  Across the lake in Laurens County, the only evidence of damage was large tree limbs that were blown out. 
## 232735                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
## 248019                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Strong thunderstorm winds knocked down a tree, many tree limbs and a flagpole in Greybull.  One and three quarter inch diameter hail fell in Greybull. 
## 248038                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       One inch diameter hail fell in Recluse and in Gillette.  The hail damaged trees and gardens in Gillette.  One outdoor booth at a rodeo in Gillette was demolished and some trailers were damaged.  At the same rodeo, 2 people sustained minor injuries due to the hail.  The hail was in drifts 6 to 8 inches deep in Gillette.
    #seeing the remarks for the records with 'h' & 'H', I am assuming that these mmost likely mean thousands 'K'
    #Let's see if there is any data with PROPDMGEXP = '?'
    subset(srcData, (PROPDMGEXP %in% c('?')) & (PROPDMG != 0) ) #? seems to only appear when the value is zero
##  [1] STATE__    BGN_DATE   BGN_TIME   TIME_ZONE  COUNTY     COUNTYNAME
##  [7] STATE      EVTYPE     BGN_RANGE  BGN_AZI    BGN_LOCATI END_DATE  
## [13] END_TIME   COUNTY_END COUNTYENDN END_RANGE  END_AZI    END_LOCATI
## [19] LENGTH     WIDTH      F          MAG        FATALITIES INJURIES  
## [25] PROPDMG    PROPDMGEXP CROPDMG    CROPDMGEXP WFO        STATEOFFIC
## [31] ZONENAMES  LATITUDE   LONGITUDE  LATITUDE_E LONGITUDE_ REMARKS   
## [37] REFNUM     HumanHarm 
## <0 rows> (or 0-length row.names)
    #we can conclude that ? only appears when the damage is zero
    
    #get the unique levels present in cropdmgexp
    levels(srcData$CROPDMGEXP)
## [1] ""  "?" "0" "2" "B" "k" "K" "m" "M"
    #add a column to represent the factors/exponents as numeric values
    srcData$PROPDMGEXP_Numeric <- as.numeric(mapvalues(srcData$PROPDMGEXP, from=levels(srcData$PROPDMGEXP), to=c("0", "0", "0", "0", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "3", "3", "3", "6", "6")))
    
    srcData$CROPDMGEXP_Numeric <- as.numeric(mapvalues(srcData$CROPDMGEXP, from=levels(srcData$CROPDMGEXP), to=c("0", "0", "0", "2", "9", "3", "3", "6", "6")))
    
    #sum up the crop and property damage data by multiplying with approrpiate exponents
    srcData$EconomicDamage <- (srcData$PROPDMG * 10^srcData$PROPDMGEXP_Numeric) + (srcData$CROPDMG * 10^srcData$CROPDMGEXP_Numeric)
    
    #groupby and sum 'HumanHarm' based on the EVTYPE
    aggSrc_EconomicDamage <- aggregate(EconomicDamage ~ EVTYPE, srcData, sum)

    #sort in descending order
    aggSrc_EconomicDamage_sorted <- aggSrc_EconomicDamage[order(-aggSrc_EconomicDamage$EconomicDamage),]

Results

the top 5 harmful events for human health are as follows

    head(aggSrc_HumanHarm_sorted, 5)
##             EVTYPE HumanHarm
## 834        TORNADO     96979
## 130 EXCESSIVE HEAT      8428
## 856      TSTM WIND      7461
## 170          FLOOD      7259
## 464      LIGHTNING      6046
    #plot the data
    tmp <- head(aggSrc_HumanHarm_sorted, 5)
    barplot(height = tmp$HumanHarm, names.arg = tmp$EVTYPE, xlab = "Event Type", ylab = "Total Human Fatalities + Injuries", main = "Weather events most harmful to Human Health, 1950-2011", col = rainbow(5))

We find that Tornado is the leading cause of adverse human health effects, followed by Excessive Heat, TSTM Wind, Flood and Lightening

the top 5 harmful events for economic value

    head(aggSrc_EconomicDamage_sorted, 5)
##                EVTYPE EconomicDamage
## 170             FLOOD   1.448752e+12
## 411 HURRICANE/TYPHOON   6.932048e+11
## 834           TORNADO   5.705008e+11
## 670       STORM SURGE   4.332354e+11
## 153       FLASH FLOOD   1.701306e+11
    #plot the data
    tmp <- head(aggSrc_EconomicDamage_sorted, 5)
    barplot(height = tmp$EconomicDamage/10e9, names.arg = tmp$EVTYPE, xlab = "Event Type", ylab = "Billions of US Dollars", main = "Weather events most harmful to Economic Value, 1950-2011", col = rainbow(5))

We find that Flood is the leading cause of economic loss, followed by Hurricane, Tornado, Surge Storm, and Flash Floods