Analysis of the Impact of Weather Events on Public Health and Economy in the United States.

Author: Javier Samir Rey Date : Saturday, June 20, 2015

Synopsis

This search aims to identify weather events that cause more harm to the health of people, on the information based on the records provided by the National Weather Service for the years 1950-2011 , this research assumes that both deaths injuries are harmful for the health of people considering that many deaths can bring health problems.

Data Processing

#Fix for publishing in rpubs:
#https://support.rstudio.com/hc/en-us/articles/205002917-SSL-certificate-problem-when-publishing-to-RPubs
library(readr)
library(R.utils)
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.7.0 (2015-02-19) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.19.0 (2015-02-27) successfully loaded. See ?R.oo for help.
## 
## Attaching package: 'R.oo'
## 
## The following objects are masked from 'package:methods':
## 
##     getClasses, getMethods
## 
## The following objects are masked from 'package:base':
## 
##     attach, detach, gc, load, save
## 
## R.utils v2.1.0 (2015-05-27) successfully loaded. See ?R.utils for help.
## 
## Attaching package: 'R.utils'
## 
## The following object is masked from 'package:utils':
## 
##     timestamp
## 
## The following objects are masked from 'package:base':
## 
##     cat, commandArgs, getOption, inherits, isOpen, parse, warnings
rm(list = ls())
bunzip2("repdata-data-StormData.csv.bz2", overwrite=T, remove=F)
stormData <- suppressWarnings(read_csv("repdata-data-StormData.csv"))
## 
|================================================================================| 100%  535 MB
dim(stormData)
## [1] 902297     37
str(stormData)
## Classes 'tbl_df', 'tbl' and 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : chr  "4/18/1950 0:00:00" "4/18/1950 0:00:00" "2/20/1951 0:00:00" "6/8/1951 0:00:00" ...
##  $ BGN_TIME  : int  130 145 1600 900 1500 2000 100 900 2000 2000 ...
##  $ TIME_ZONE : chr  "CST" "CST" "CST" "CST" ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: chr  "MOBILE" "BALDWIN" "FAYETTE" "MADISON" ...
##  $ STATE     : chr  "AL" "AL" "AL" "AL" ...
##  $ EVTYPE    : chr  "TORNADO" "TORNADO" "TORNADO" "TORNADO" ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : logi  NA NA NA NA NA NA ...
##  $ BGN_LOCATI: logi  NA NA NA NA NA NA ...
##  $ END_DATE  : logi  NA NA NA NA NA NA ...
##  $ END_TIME  : logi  NA NA NA NA NA NA ...
##  $ 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   : logi  NA NA NA NA NA NA ...
##  $ END_LOCATI: logi  NA NA NA NA NA NA ...
##  $ 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: chr  "K" "K" "K" "K" ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: logi  NA NA NA NA NA NA ...
##  $ WFO       : logi  NA NA NA NA NA NA ...
##  $ STATEOFFIC: logi  NA NA NA NA NA NA ...
##  $ ZONENAMES : logi  NA NA NA NA NA NA ...
##  $ 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   : logi  NA NA NA NA NA NA ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...
##  - attr(*, "problems")=Classes 'tbl_df', 'tbl' and 'data.frame': 6139392 obs. of  4 variables:
##   ..$ row     : int  1671 1673 1674 1675 1678 1679 1680 1681 1682 1683 ...
##   ..$ col     : int  29 29 29 29 29 29 29 29 29 29 ...
##   ..$ expected: chr  "T/F/TRUE/FALSE" "T/F/TRUE/FALSE" "T/F/TRUE/FALSE" "T/F/TRUE/FALSE" ...
##   ..$ actual  : chr  "NG" "NG" "NG" "NG" ...
head(stormData)
##   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      NA         NA       NA       NA          0
## 2 TORNADO         0      NA         NA       NA       NA          0
## 3 TORNADO         0      NA         NA       NA       NA          0
## 4 TORNADO         0      NA         NA       NA       NA          0
## 5 TORNADO         0      NA         NA       NA       NA          0
## 6 TORNADO         0      NA         NA       NA       NA          0
##   COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1         NA         0      NA         NA   14.0   100 3   0          0
## 2         NA         0      NA         NA    2.0   150 2   0          0
## 3         NA         0      NA         NA    0.1   123 2   0          0
## 4         NA         0      NA         NA    0.0   100 2   0          0
## 5         NA         0      NA         NA    0.0   150 2   0          0
## 6         NA         0      NA         NA    1.5   177 2   0          0
##   INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1       15    25.0          K       0         NA  NA         NA        NA
## 2        0     2.5          K       0         NA  NA         NA        NA
## 3        2    25.0          K       0         NA  NA         NA        NA
## 4        2     2.5          K       0         NA  NA         NA        NA
## 5        2     2.5          K       0         NA  NA         NA        NA
## 6        6     2.5          K       0         NA  NA         NA        NA
##   LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1     3040      8812       3051       8806      NA      1
## 2     3042      8755          0          0      NA      2
## 3     3340      8742          0          0      NA      3
## 4     3458      8626          0          0      NA      4
## 5     3412      8642          0          0      NA      5
## 6     3450      8748          0          0      NA      6
summary(stormData[,c(8,23,24,25,27)])
##     EVTYPE            FATALITIES          INJURIES        
##  Length:902297      Min.   :  0.0000   Min.   :   0.0000  
##  Class :character   1st Qu.:  0.0000   1st Qu.:   0.0000  
##  Mode  :character   Median :  0.0000   Median :   0.0000  
##                     Mean   :  0.0168   Mean   :   0.1557  
##                     3rd Qu.:  0.0000   3rd Qu.:   0.0000  
##                     Max.   :583.0000   Max.   :1700.0000  
##     PROPDMG           CROPDMG       
##  Min.   :   0.00   Min.   :  0.000  
##  1st Qu.:   0.00   1st Qu.:  0.000  
##  Median :   0.00   Median :  0.000  
##  Mean   :  12.06   Mean   :  1.527  
##  3rd Qu.:   0.50   3rd Qu.:  0.000  
##  Max.   :5000.00   Max.   :990.000
colnames(stormData)
##  [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"
#Normalize names
colnames(stormData)[8] <- "evtype" 
colnames(stormData)[23] <- "fatalities"
colnames(stormData)[24] <- "injuries"
colnames(stormData)[25] <- "propdmg"
colnames(stormData)[27] <- "cropdmg"

Results - Impact in Population Health

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

Prepare data for analysis it does the following:

  • Cleaning some data
  • Grouping by event type and calculate the sum of injuries together fatalities.
  • Filter out events with no fatalities and injuries.
  • Sort the table with items with the highest fatalities and injuries in top.
  • Selected top 20.
library(dplyr)
## 
## Attaching package: 'dplyr'
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)

stormData$evtype[stormData$evtype == "THUNDERSTORM WINDS"] <- "THUNDERSTORM WIND"

stormByEvent <- stormData %>% 
    group_by(evtype) %>% 
    summarise(harmful = sum(fatalities + injuries)) %>%
    filter(harmful > 0) %>%
    arrange(desc(harmful)) 

stormByEventGraph <- stormByEvent[1:20,]
head(stormByEventGraph)
## Source: local data frame [6 x 2]
## 
##           evtype harmful
## 1        TORNADO   96979
## 2 EXCESSIVE HEAT    8428
## 3      TSTM WIND    7461
## 4          FLOOD    7259
## 5      LIGHTNING    6046
## 6           HEAT    3037
g <- ggplot(stormByEventGraph, aes(x=reorder(evtype, harmful), y = harmful)) 
g <- g + geom_bar(stat="identity", colour = "#43e8d8", fill = "#43e8d8") 
g <- g + labs(title = "Top Event Types (Population Health)", x = "Event Type", y = "Fatalities and Injuires")
g <- g + theme(plot.title = element_text(color="#666666", face="bold", size=19))
g <- g + theme(axis.title = element_text(color="#666666", face="bold", size=19))
g <- g + coord_flip()
g

Results - Impact in Economic

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

Prepare data for analysis it does the following:

  • Grouping by event type and calculate the sum of propdmg together cropdmg.
  • Filter out events with no propdmg and cropdmg.
  • Sort the table with items with the highest fatalities and injuries in top.
  • Selected top 20.
stormByEvent <- stormData %>% 
    group_by(evtype) %>% 
    summarise(economic = sum(propdmg + cropdmg)) %>%
    filter(economic > 0) %>%
    arrange(desc(economic)) 

stormByEventGraph <- stormByEvent[1:20,]
head(stormByEventGraph)
## Source: local data frame [6 x 2]
## 
##              evtype economic
## 1           TORNADO  3312277
## 2       FLASH FLOOD  1599325
## 3         TSTM WIND  1445168
## 4 THUNDERSTORM WIND  1408614
## 5              HAIL  1268290
## 6             FLOOD  1067976
g <- ggplot(stormByEventGraph, aes(x=reorder(evtype, economic), y = economic)) 
g <- g + geom_bar(stat="identity", colour = "#43e8d8", fill = "#43e8d8") 
g <- g + labs(title = "Top Event Types (Greatest Economic Consequences)", x = "Event Type", y = "Economy Damage")
g <- g + theme(plot.title = element_text(color="#666666", face="bold", size=19))
g <- g + theme(axis.title = element_text(color="#666666", face="bold", size=19))
g <- g + coord_flip()
g

Conclusion

From these data, we found that excessive heat and tornado are most harmful with respect to population health, while tornado and flash flood have the greatest economic consequences.