Synopsis

This report is a requirement for the Coursera Data Science specialization course: Reproducible Research. The verbosity is intentional, to demonstrate the complete sequence of steps used to produce the results.

The two questions addressed are:

  1. Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?

  2. Across the United States, which types of events have the greatest economic consequences?

The event types were consolidated to broader groupings. In terms of human fatalities and injuries, tornadoes rank the highest. In terms of property damage, hurricanes and tropical storms rank the highest with over three quarters of the cost attributed to them.

The data was filtered to years 1995-2011 since prior to 1995 reporting appeared incomplete based on event counts.

Data Processing

Storm data was downloaded from https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2, and documentation about this data can be downloaded from here: https://d396qusza40orc.cloudfront.net/repdata%2Fpeer2_doc%2Fpd01016005curr.pdf.

The environment used is:

#Sys.info()
#R.Version()
require(plyr)
## Loading required package: plyr
require(dplyr)
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## 
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
require(ggplot2)
## Loading required package: ggplot2
require(grid) # to use unit() in ggplot
## Loading required package: grid

The dataset was uncompressed into a file named repdata_data_StormData.csv using the winZip utility in a 64-bit windows-10 environment, and placed in a project directory. The following steps were used to load a data frame called rawData and perform basic exploratory analysis.

rawData<-read.csv("repdata_data_StormData.csv")
object.size(rawData)
## 429322384 bytes
names(rawData)
##  [1] "STATE__"    "BGN_DATE"   "BGN_TIME"   "TIME_ZONE"  "COUNTY"    
##  [6] "COUNTYNAME" "STATE"      "EVTYPE"     "BGN_RANGE"  "BGN_AZI"   
## [11] "BGN_LOCATI" "END_DATE"   "END_TIME"   "COUNTY_END" "COUNTYENDN"
## [16] "END_RANGE"  "END_AZI"    "END_LOCATI" "LENGTH"     "WIDTH"     
## [21] "F"          "MAG"        "FATALITIES" "INJURIES"   "PROPDMG"   
## [26] "PROPDMGEXP" "CROPDMG"    "CROPDMGEXP" "WFO"        "STATEOFFIC"
## [31] "ZONENAMES"  "LATITUDE"   "LONGITUDE"  "LATITUDE_E" "LONGITUDE_"
## [36] "REMARKS"    "REFNUM"
sapply(rawData[1,],class)
##    STATE__   BGN_DATE   BGN_TIME  TIME_ZONE     COUNTY COUNTYNAME 
##  "numeric"   "factor"   "factor"   "factor"  "numeric"   "factor" 
##      STATE     EVTYPE  BGN_RANGE    BGN_AZI BGN_LOCATI   END_DATE 
##   "factor"   "factor"  "numeric"   "factor"   "factor"   "factor" 
##   END_TIME COUNTY_END COUNTYENDN  END_RANGE    END_AZI END_LOCATI 
##   "factor"  "numeric"  "logical"  "numeric"   "factor"   "factor" 
##     LENGTH      WIDTH          F        MAG FATALITIES   INJURIES 
##  "numeric"  "numeric"  "integer"  "numeric"  "numeric"  "numeric" 
##    PROPDMG PROPDMGEXP    CROPDMG CROPDMGEXP        WFO STATEOFFIC 
##  "numeric"   "factor"  "numeric"   "factor"   "factor"   "factor" 
##  ZONENAMES   LATITUDE  LONGITUDE LATITUDE_E LONGITUDE_    REMARKS 
##   "factor"  "numeric"  "numeric"  "numeric"  "numeric"   "factor" 
##     REFNUM 
##  "numeric"
str(rawData)
## 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : Factor w/ 16335 levels "1/1/1966 0:00:00",..: 6523 6523 4242 11116 2224 2224 2260 383 3980 3980 ...
##  $ BGN_TIME  : Factor w/ 3608 levels "00:00:00 AM",..: 272 287 2705 1683 2584 3186 242 1683 3186 3186 ...
##  $ TIME_ZONE : Factor w/ 22 levels "ADT","AKS","AST",..: 7 7 7 7 7 7 7 7 7 7 ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: Factor w/ 29601 levels "","5NM E OF MACKINAC BRIDGE TO PRESQUE ISLE LT MI",..: 13513 1873 4598 10592 4372 10094 1973 23873 24418 4598 ...
##  $ STATE     : Factor w/ 72 levels "AK","AL","AM",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ EVTYPE    : Factor w/ 985 levels "   HIGH SURF ADVISORY",..: 834 834 834 834 834 834 834 834 834 834 ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : Factor w/ 35 levels "","  N"," NW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_LOCATI: Factor w/ 54429 levels "","- 1 N Albion",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_DATE  : Factor w/ 6663 levels "","1/1/1993 0:00:00",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_TIME  : Factor w/ 3647 levels ""," 0900CST",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : Factor w/ 24 levels "","E","ENE","ESE",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_LOCATI: Factor w/ 34506 levels "","- .5 NNW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: Factor w/ 19 levels "","-","?","+",..: 17 17 17 17 17 17 17 17 17 17 ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: Factor w/ 9 levels "","?","0","2",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ WFO       : Factor w/ 542 levels ""," CI","$AC",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ STATEOFFIC: Factor w/ 250 levels "","ALABAMA, Central",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ ZONENAMES : Factor w/ 25112 levels "","                                                                                                                               "| __truncated__,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : Factor w/ 436774 levels "","-2 at Deer Park\n",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...
summary(rawData)
##     STATE__                  BGN_DATE             BGN_TIME     
##  Min.   : 1.0   5/25/2011 0:00:00:  1202   12:00:00 AM: 10163  
##  1st Qu.:19.0   4/27/2011 0:00:00:  1193   06:00:00 PM:  7350  
##  Median :30.0   6/9/2011 0:00:00 :  1030   04:00:00 PM:  7261  
##  Mean   :31.2   5/30/2004 0:00:00:  1016   05:00:00 PM:  6891  
##  3rd Qu.:45.0   4/4/2011 0:00:00 :  1009   12:00:00 PM:  6703  
##  Max.   :95.0   4/2/2006 0:00:00 :   981   03:00:00 PM:  6700  
##                 (Other)          :895866   (Other)    :857229  
##    TIME_ZONE          COUNTY           COUNTYNAME         STATE       
##  CST    :547493   Min.   :  0.0   JEFFERSON :  7840   TX     : 83728  
##  EST    :245558   1st Qu.: 31.0   WASHINGTON:  7603   KS     : 53440  
##  MST    : 68390   Median : 75.0   JACKSON   :  6660   OK     : 46802  
##  PST    : 28302   Mean   :100.6   FRANKLIN  :  6256   MO     : 35648  
##  AST    :  6360   3rd Qu.:131.0   LINCOLN   :  5937   IA     : 31069  
##  HST    :  2563   Max.   :873.0   MADISON   :  5632   NE     : 30271  
##  (Other):  3631                   (Other)   :862369   (Other):621339  
##                EVTYPE         BGN_RANGE           BGN_AZI      
##  HAIL             :288661   Min.   :   0.000          :547332  
##  TSTM WIND        :219940   1st Qu.:   0.000   N      : 86752  
##  THUNDERSTORM WIND: 82563   Median :   0.000   W      : 38446  
##  TORNADO          : 60652   Mean   :   1.484   S      : 37558  
##  FLASH FLOOD      : 54277   3rd Qu.:   1.000   E      : 33178  
##  FLOOD            : 25326   Max.   :3749.000   NW     : 24041  
##  (Other)          :170878                      (Other):134990  
##          BGN_LOCATI                  END_DATE             END_TIME     
##               :287743                    :243411              :238978  
##  COUNTYWIDE   : 19680   4/27/2011 0:00:00:  1214   06:00:00 PM:  9802  
##  Countywide   :   993   5/25/2011 0:00:00:  1196   05:00:00 PM:  8314  
##  SPRINGFIELD  :   843   6/9/2011 0:00:00 :  1021   04:00:00 PM:  8104  
##  SOUTH PORTION:   810   4/4/2011 0:00:00 :  1007   12:00:00 PM:  7483  
##  NORTH PORTION:   784   5/30/2004 0:00:00:   998   11:59:00 PM:  7184  
##  (Other)      :591444   (Other)          :653450   (Other)    :622432  
##    COUNTY_END COUNTYENDN       END_RANGE           END_AZI      
##  Min.   :0    Mode:logical   Min.   :  0.0000          :724837  
##  1st Qu.:0    NA's:902297    1st Qu.:  0.0000   N      : 28082  
##  Median :0                   Median :  0.0000   S      : 22510  
##  Mean   :0                   Mean   :  0.9862   W      : 20119  
##  3rd Qu.:0                   3rd Qu.:  0.0000   E      : 20047  
##  Max.   :0                   Max.   :925.0000   NE     : 14606  
##                                                 (Other): 72096  
##            END_LOCATI         LENGTH              WIDTH         
##                 :499225   Min.   :   0.0000   Min.   :   0.000  
##  COUNTYWIDE     : 19731   1st Qu.:   0.0000   1st Qu.:   0.000  
##  SOUTH PORTION  :   833   Median :   0.0000   Median :   0.000  
##  NORTH PORTION  :   780   Mean   :   0.2301   Mean   :   7.503  
##  CENTRAL PORTION:   617   3rd Qu.:   0.0000   3rd Qu.:   0.000  
##  SPRINGFIELD    :   575   Max.   :2315.0000   Max.   :4400.000  
##  (Other)        :380536                                         
##        F               MAG            FATALITIES          INJURIES        
##  Min.   :0.0      Min.   :    0.0   Min.   :  0.0000   Min.   :   0.0000  
##  1st Qu.:0.0      1st Qu.:    0.0   1st Qu.:  0.0000   1st Qu.:   0.0000  
##  Median :1.0      Median :   50.0   Median :  0.0000   Median :   0.0000  
##  Mean   :0.9      Mean   :   46.9   Mean   :  0.0168   Mean   :   0.1557  
##  3rd Qu.:1.0      3rd Qu.:   75.0   3rd Qu.:  0.0000   3rd Qu.:   0.0000  
##  Max.   :5.0      Max.   :22000.0   Max.   :583.0000   Max.   :1700.0000  
##  NA's   :843563                                                           
##     PROPDMG          PROPDMGEXP        CROPDMG          CROPDMGEXP    
##  Min.   :   0.00          :465934   Min.   :  0.000          :618413  
##  1st Qu.:   0.00   K      :424665   1st Qu.:  0.000   K      :281832  
##  Median :   0.00   M      : 11330   Median :  0.000   M      :  1994  
##  Mean   :  12.06   0      :   216   Mean   :  1.527   k      :    21  
##  3rd Qu.:   0.50   B      :    40   3rd Qu.:  0.000   0      :    19  
##  Max.   :5000.00   5      :    28   Max.   :990.000   B      :     9  
##                    (Other):    84                     (Other):     9  
##       WFO                                       STATEOFFIC    
##         :142069                                      :248769  
##  OUN    : 17393   TEXAS, North                       : 12193  
##  JAN    : 13889   ARKANSAS, Central and North Central: 11738  
##  LWX    : 13174   IOWA, Central                      : 11345  
##  PHI    : 12551   KANSAS, Southwest                  : 11212  
##  TSA    : 12483   GEORGIA, North and Central         : 11120  
##  (Other):690738   (Other)                            :595920  
##                                                                                                                                                                                                     ZONENAMES     
##                                                                                                                                                                                                          :594029  
##                                                                                                                                                                                                          :205988  
##  GREATER RENO / CARSON CITY / M - GREATER RENO / CARSON CITY / M                                                                                                                                         :   639  
##  GREATER LAKE TAHOE AREA - GREATER LAKE TAHOE AREA                                                                                                                                                       :   592  
##  JEFFERSON - JEFFERSON                                                                                                                                                                                   :   303  
##  MADISON - MADISON                                                                                                                                                                                       :   302  
##  (Other)                                                                                                                                                                                                 :100444  
##     LATITUDE      LONGITUDE        LATITUDE_E     LONGITUDE_    
##  Min.   :   0   Min.   :-14451   Min.   :   0   Min.   :-14455  
##  1st Qu.:2802   1st Qu.:  7247   1st Qu.:   0   1st Qu.:     0  
##  Median :3540   Median :  8707   Median :   0   Median :     0  
##  Mean   :2875   Mean   :  6940   Mean   :1452   Mean   :  3509  
##  3rd Qu.:4019   3rd Qu.:  9605   3rd Qu.:3549   3rd Qu.:  8735  
##  Max.   :9706   Max.   : 17124   Max.   :9706   Max.   :106220  
##  NA's   :47                      NA's   :40                     
##                                            REMARKS           REFNUM      
##                                                :287433   Min.   :     1  
##                                                : 24013   1st Qu.:225575  
##  Trees down.\n                                 :  1110   Median :451149  
##  Several trees were blown down.\n              :   569   Mean   :451149  
##  Trees were downed.\n                          :   446   3rd Qu.:676723  
##  Large trees and power lines were blown down.\n:   432   Max.   :902297  
##  (Other)                                       :588294

An event date (date class) was created based on the beginning date of each event. Also damage estimates were normalized based on the exponent. For numeric exponents we assume a power of 10. Otherwise 0 was used for invalid characters such as “?” “+” etc., 3 for K, 6 for M and 9 for B. By multiplying the amount value to 10 raised to the power of the normalized exponent, the respective damage amounts were derived ready to be summarized.

rawData$evdate<-as.Date(rawData$BGN_DATE,"%m/%d/%Y %H:%M:%S")

rawData$propdmgexp <- mapvalues(toupper(rawData$PROPDMGEXP),
                                c("K","M","","B","+","?","H","-"),
                                c( 3 , 6 , 0, 9 , 0 , 0 , 2 , 0 ))
rawData$cropdmgexp <- mapvalues(toupper(rawData$PROPDMGEXP),
                                c("K","M","","B","+","?","H","-"),
                                c( 3 , 6 , 0, 9 , 0 , 0 , 2 , 0 ))

We generate a summary by event by year and verify that summary events carry no damage, fatality or injury values, so there is no concern of double-counting.

event.agg <- rawData %>% 
    group_by(EVTYPE,year=format(evdate,"%Y")) %>%
    summarize(
        evcount = sum(!is.na(EVTYPE)), 
        propdmg.M=sum(PROPDMG*10^(as.numeric(propdmgexp)-6)),
        cropdmg.M=sum(CROPDMG*10^(as.numeric(cropdmgexp)-6)), 
        fatalities=sum(FATALITIES),
        injuries=sum(INJURIES)) %>%
        mutate(is.summary = grepl(".*summ.*",EVTYPE,ignore.case=TRUE))

# check if summary events carry counts and amounts
event.agg %>%
    group_by(is.summary) %>%
    summarize(
        propdmg=sum(propdmg.M),
        cropdmg=sum(cropdmg.M),
        injuries=sum(injuries),
        fatalities=sum(fatalities)
        )
## Source: local data frame [2 x 5]
## 
##   is.summary  propdmg cropdmg injuries fatalities
##        (lgl)    (dbl)   (dbl)    (dbl)      (dbl)
## 1      FALSE 428224.9 1775227   140528      15145
## 2       TRUE      0.0       0        0          0
# Look at the yearly summary of event data collected
sum.yearly.nonsummary <- event.agg %>%
    filter(!is.summary) %>% 
    group_by(year) %>%
    summarize(
        evcount=sum(evcount),
        propdmg=sum(propdmg.M),
        cropdmg=sum(cropdmg.M),
        injuries=sum(injuries),
        fatalities=sum(fatalities)
        )
ggplot(data=sum.yearly.nonsummary) +
    geom_bar(aes(x=year,y=evcount),fill="blue",stat="identity")  +
    scale_x_discrete(breaks=seq(1950,2010,5)) +
    ggtitle("Weather Events Recorded by Year")

# exclude summary events and years prior to 1994
sum.evtypes <- event.agg %>% 
    filter(!is.summary) %>% 
    filter(year > 1994 ) %>%
    group_by(EVTYPE) %>%
    summarize(
        evcount=sum(evcount),
        propdmg=sum(propdmg.M),
        cropdmg=sum(cropdmg.M),
        injuries=sum(injuries),
        fatalities=sum(fatalities)
        )

The completeness of events reported has improved in recent years, so we limit our estimates to the range of years 1995-2011. As evidenced by the plethora and apparent redundancy of event types (EVTYPE) a better organization of the events is required. As an example, hail is broken down based on its size and similar classifications exist for thunderstorms, tornadoes and many other events. We organize these events using a classifier we call supertype so that we can more reliably summarize and compare the data.

We follow the following process:

evTypes<-toupper(sum.evtypes$EVTYPE)
length(evTypes)
## [1] 732
sum.evsupertypes <- sum.evtypes %>%
    mutate(evsupertype = ifelse(grepl(".*(BLIZZ|SNOW|ICE).*",EVTYPE,ignore.case = TRUE) 
                                ,"BLIZARD/SNOW/ICE",NA)) %>%
    mutate(evsupertype = ifelse(grepl(".*TORNAD.*",EVTYPE,ignore.case = TRUE)
                                & is.na(evsupertype)
                                ,"TORNADO",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*WATERSP.*",EVTYPE,ignore.case = TRUE)
                                & is.na(evsupertype)
                                ,"WATERSPOUT",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*THUNDERS.*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"THUNDERSTORM",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*HAIL.*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"HAIL",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*WIND.*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"WIND",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*FLOOD.*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"FLOOD",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*(RECORD|UNSEASON|ABNORMA).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"EXTREME CONDITIONS",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*(VOLCAN).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"VOLCANIC EVENT",evsupertype ))  %>%
    mutate(evsupertype = ifelse(grepl(".*(FLOOD).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"FLOOD",evsupertype ))  %>%
    mutate(evsupertype = ifelse(grepl(".*(LIGHTN).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"LIGHTNING",evsupertype ))   %>%
    mutate(evsupertype = ifelse(grepl(".*(FIRE).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"FIRE",evsupertype ))   %>%
    mutate(evsupertype = ifelse(grepl(".*(FREEZIN).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"FREEZING RAIN/FOG",evsupertype ))  %>%
    mutate(evsupertype = ifelse(grepl(".*(WAVE|SURF).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"WAVE/SURF",evsupertype ))  %>%
    mutate(evsupertype = ifelse(grepl(".*(HURRIC|TROPIC|STORM).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"STORM/HURRICANE",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*( RIP |CURRENT).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"RIP CURRENT",evsupertype )) %>%
    mutate(evsupertype = ifelse(grepl(".*(FREEZE|COLD|ICY|HYPOTHERM).*",EVTYPE,ignore.case = TRUE) 
                                & is.na(evsupertype)
                                ,"FREEZE/COLD",evsupertype )) 

S0<- sum.evsupertypes %>%
        mutate(evsupertype = ifelse(is.na(evsupertype)
                                ,as.character(EVTYPE),evsupertype )) %>%
    summarize(
        dmg.B.USD=sum(propdmg+cropdmg)/1000,
        injuries=sum(injuries),
        fatalities=sum(fatalities),
        casualties=sum(fatalities+injuries)
    )

S1<- sum.evsupertypes %>%
        mutate(evsupertype = ifelse(is.na(evsupertype)
                                ,as.character(EVTYPE),evsupertype )) %>%
    group_by(evsupertype) %>%
    summarize(
#       evcount=sum(evcount),
#        propdmg=sum(propdmg),
#        cropdmg=sum(cropdmg),
        dmg.B.USD=sum(propdmg+cropdmg)/1000,
        injuries=sum(injuries),
        fatalities=sum(fatalities),
        casualties=sum(fatalities+injuries)
    )  %>%
        arrange(desc(casualties)) %>%
#    slice(1:15)
    top_n(10,casualties)
S10 <- S1 %>%     
    summarize(
        dmg.B.USD=sum(dmg.B.USD),
        injuries=sum(injuries),
        fatalities=sum(fatalities),
        casualties=sum(casualties)
    )
S10<- S0-S10
S10$evsupertype = "ALL OTHER"
S1 <- rbind(S1,S10)
S2<- sum.evsupertypes %>%
        mutate(evsupertype = ifelse(is.na(evsupertype)
                                ,as.character(EVTYPE),evsupertype )) %>%
    group_by(evsupertype) %>%
    summarize(
#       evcount=sum(evcount),
#        propdmg=sum(propdmg),
#        cropdmg=sum(cropdmg),
        dmg.B.USD=sum(propdmg+cropdmg)/1000,
        injuries=sum(injuries),
        fatalities=sum(fatalities),
        casualties=sum(fatalities+injuries)
    )  %>%
        arrange(desc(dmg.B.USD)) %>%
#    slice(1:15)
    top_n(4,dmg.B.USD)
S20 <- S2 %>%     
    summarize(
        dmg.B.USD=sum(dmg.B.USD),
        injuries=sum(injuries),
        fatalities=sum(fatalities),
        casualties=sum(fatalities+injuries)
    )
S20<- S0-S20
S20$evsupertype = "ALL OTHER"
S2 <- rbind(S2,S20)

    
E1 <- sum.evsupertypes[is.na(sum.evsupertypes$evsupertype),] %>% 
    filter(fatalities+injuries+propdmg+cropdmg > 0) %>% 
    group_by(EVTYPE)

Results

The following table shows the top 10 weather events in the US from 1995 to 2011 in terms of fatalities and injuries. The table is followed by a pie-chart demonstrating the proportion of these casualties.

require(xtable)
## Loading required package: xtable
tab.print<-xtable(S1,label="Events with Highest Human Casualties",caption="Event Types with Highest human casualties")
print(tab.print,type="html", floating=FALSE)
evsupertype dmg.B.USD injuries fatalities casualties
1 TORNADO 50.84 21787.00 1545.00 23332.00
2 FLOOD 281.43 8519.00 1386.00 9905.00
3 EXCESSIVE HEAT 0.01 6525.00 1903.00 8428.00
4 WIND 35.15 5324.00 899.00 6223.00
5 LIGHTNING 1.10 4632.00 730.00 5362.00
6 STORM/HURRICANE 1684.91 3427.00 423.00 3850.00
7 HEAT 0.00 2030.00 924.00 2954.00
8 THUNDERSTORM 11.42 1950.00 182.00 2132.00
9 BLIZARD/SNOW/ICE 5.89 1596.00 310.00 1906.00
10 FIRE 15.03 1458.00 87.00 1545.00
11 ALL OTHER 39.30 5207.00 1834.00 7041.00
y.breaks <- cumsum(S1$casualties) - S1$casualties/2
y.breaks
##  [1] 11666.0 28284.5 37451.0 44776.5 50569.0 55175.0 58577.0 61120.0
##  [9] 63139.0 64864.5 69157.5
ggplot(S1, aes(x=factor(1),casualties , fill=evsupertype)) +geom_bar(stat="identity", width=1) +
    coord_polar(theta = "y") +
    #geom_bar(stat="identity", color='black') +   # black border around pie slices    
    #scale_fill_brewer(palette = "Set3") +        # override default color palette
    theme(axis.text.x=element_text(color='black'  # axis text style
                                   ,size=8)) +
    theme(axis.ticks=element_blank()      # the axis ticks
          ,axis.title=element_blank()     # the axis labels
          ,axis.text.y=element_blank()    # the numeric labels.
    ) +
    theme(legend.position="right") + # position bottom,left,right etc.
    #theme(plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "in")) + 
    #guides(fill=guide_legend(override.aes=list(colour=NA))) + # remove diagonal from legend
    scale_y_continuous(
        breaks=y.breaks,   # where to place the labels
        labels=S1$evsupertype
    ) +
    ggtitle("1995-2011 Most Costly Storm Events\nTop 10 in Combined Injuries and fatalities")

The table that follows summarizes weather event groupings in terms of property and crop damage recorded from 1995 to 2011 in the US. A pie-chart showing the same breakdown follows.

require(xtable)
tab.print<-xtable(S2,label="Events Causing Highest Damages",caption="Event Types causing Highest damage")
print(tab.print,type="html", floating=FALSE)
evsupertype dmg.B.USD injuries fatalities casualties
1 STORM/HURRICANE 1684.91 3427.00 423.00 3850.00
2 FLOOD 281.43 8519.00 1386.00 9905.00
3 TORNADO 50.84 21787.00 1545.00 23332.00
4 WIND 35.15 5324.00 899.00 6223.00
5 ALL OTHER 72.75 23398.00 5970.00 29368.00
y.breaks <- cumsum(S2$dmg.B.USD) - S2$dmg.B.USD/2
y.breaks
## [1]  842.4559 1825.6281 1991.7620 2034.7523 2088.6990
ggplot(S2, aes(x=factor(1),dmg.B.USD , fill=evsupertype)) +geom_bar(stat="identity", width=1) +
    coord_polar(theta = "y") +
#    geom_bar(stat="identity", color='black') +       
    #scale_fill_brewer(palette = "Set3") + 
    theme(axis.text.x=element_text(color='black'  # axis text style
                                   ,size=8)) +
    theme(axis.ticks=element_blank()  # the axis ticks
          ,axis.title=element_blank()  # the axis labels
          ,axis.text.y=element_blank() # the 0.75, 1.00, 1.25 labels.
          ,legend.position="right") +
#    theme(plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "in")) + 
#    guides(fill=guide_legend(override.aes=list(colour=NA))) + # remove diagonal from legend
#    scale_y_continuous(
#        breaks=y.breaks,   # where to place the labels
#        labels=S2$evsupertype # the labels
#    ) +
    ggtitle("1995-2011 Reported Severe Weather Events\nTop Causes of Property and Crop Damage (Billion USD)")