Project Name: Using the United States NOAA Storm Database to explore the affect of severe weather conditions-Public health & Economic consequences

Synopsis:

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.

The 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 property damage.

We subset the fatalities, injuries, property damage and crop damage from the dataset to present the results.

Finding the answers to the following

1.Top weather events that are harmful to public health 2.Top events that had severe damage to the properties and crops

Preprocessing of the NOAA Storm Data zip file downloaded from the coursera to the working directory

unzipping the csv file in to the working directory

unzip("repdata_data_activity.zip")

loading the data and creating new data file

stormdata <- read.csv("repdata_data_StormData.csv", sep = ",", header = T)
head(stormdata)
##   STATE__           BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1       1  4/18/1950 0:00:00     0130       CST     97     MOBILE    AL
## 2       1  4/18/1950 0:00:00     0145       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     0900       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         NA         0                      14.0   100 3   0          0
## 2         NA         0                       2.0   150 2   0          0
## 3         NA         0                       0.1   123 2   0          0
## 4         NA         0                       0.0   100 2   0          0
## 5         NA         0                       0.0   150 2   0          0
## 6         NA         0                       1.5   177 2   0          0
##   INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1       15    25.0          K       0                                    
## 2        0     2.5          K       0                                    
## 3        2    25.0          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
## 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

subsetting the required columns

substormdata <- stormdata[,c(8,23:28)]
head(substormdata)
##    EVTYPE FATALITIES INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP
## 1 TORNADO          0       15    25.0          K       0           
## 2 TORNADO          0        0     2.5          K       0           
## 3 TORNADO          0        2    25.0          K       0           
## 4 TORNADO          0        2     2.5          K       0           
## 5 TORNADO          0        2     2.5          K       0           
## 6 TORNADO          0        6     2.5          K       0

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

DATA ANALYSIS:

Aggregating number of injuries and fatalities to derive the events that are harmful to public health

injuries_data <- aggregate(INJURIES~EVTYPE, substormdata, sum)
injuries_data <- arrange(injuries_data, desc(INJURIES))
injuries_data <- injuries_data[1:20,]
injuries_data
##                EVTYPE INJURIES
## 1             TORNADO    91346
## 2           TSTM WIND     6957
## 3               FLOOD     6789
## 4      EXCESSIVE HEAT     6525
## 5           LIGHTNING     5230
## 6                HEAT     2100
## 7           ICE STORM     1975
## 8         FLASH FLOOD     1777
## 9   THUNDERSTORM WIND     1488
## 10               HAIL     1361
## 11       WINTER STORM     1321
## 12  HURRICANE/TYPHOON     1275
## 13          HIGH WIND     1137
## 14         HEAVY SNOW     1021
## 15           WILDFIRE      911
## 16 THUNDERSTORM WINDS      908
## 17           BLIZZARD      805
## 18                FOG      734
## 19   WILD/FOREST FIRE      545
## 20         DUST STORM      440
fatalities_data <- aggregate(FATALITIES~EVTYPE, substormdata, sum)
fatalities_data <- arrange(fatalities_data,desc(FATALITIES))
fatalities_data <- fatalities_data[1:20,]
fatalities_data
##                     EVTYPE FATALITIES
## 1                  TORNADO       5633
## 2           EXCESSIVE HEAT       1903
## 3              FLASH FLOOD        978
## 4                     HEAT        937
## 5                LIGHTNING        816
## 6                TSTM WIND        504
## 7                    FLOOD        470
## 8              RIP CURRENT        368
## 9                HIGH WIND        248
## 10               AVALANCHE        224
## 11            WINTER STORM        206
## 12            RIP CURRENTS        204
## 13               HEAT WAVE        172
## 14            EXTREME COLD        160
## 15       THUNDERSTORM WIND        133
## 16              HEAVY SNOW        127
## 17 EXTREME COLD/WIND CHILL        125
## 18             STRONG WIND        103
## 19                BLIZZARD        101
## 20               HIGH SURF        101

Total number of injuries and fatalities

mergeddata <- merge(injuries_data, fatalities_data, by = "EVTYPE")
harmful_events <- arrange(mergeddata, desc(FATALITIES+INJURIES))
head(harmful_events)
##           EVTYPE INJURIES FATALITIES
## 1        TORNADO    91346       5633
## 2 EXCESSIVE HEAT     6525       1903
## 3      TSTM WIND     6957        504
## 4          FLOOD     6789        470
## 5      LIGHTNING     5230        816
## 6           HEAT     2100        937

RESULT

Barplot showing the top 20 most harmful events with respect to population health across the United States

names_of_events <- harmful_events$EVTYPE
barplot(t(harmful_events[,-1]),names.arg = names_of_events, beside= T, col = c("green", "red"), cex.names= 0.8, las=2, ylim = c(0,92000), 
        main = "Harmful events with respect to Public health",ylab="Number of injuries and fatalities")
legend("topright",c("fatlalities","injuries"), fill = c("green","red"),bty = "n")

TORNADO are the most harmful to the population health across the U.S.

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

DATA ANALYISIS

head(substormdata)
##    EVTYPE FATALITIES INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP
## 1 TORNADO          0       15    25.0          K       0           
## 2 TORNADO          0        0     2.5          K       0           
## 3 TORNADO          0        2    25.0          K       0           
## 4 TORNADO          0        2     2.5          K       0           
## 5 TORNADO          0        2     2.5          K       0           
## 6 TORNADO          0        6     2.5          K       0
table(substormdata$PROPDMGEXP)
## 
##             -      ?      +      0      1      2      3      4      5 
## 465934      1      8      5    216     25     13      4      4     28 
##      6      7      8      B      h      H      K      m      M 
##      4      5      1     40      1      6 424665      7  11330
table(substormdata$CROPDMGEXP)
## 
##             ?      0      2      B      k      K      m      M 
## 618413      7     19      1      9     21 281832      1   1994

created new variables PROPDAMAGE and CROPDAMAGE (Damage in USD) from the PROPDMG and CROPDMG respectively

EXPENSE codes: H = Hundred= 10^2, K = Thousand= 10^3, M = Million=10^6, B = Billion=10^9

substormdata$PROPDAMAGE <- 0
substormdata[substormdata$PROPDMGEXP == "H", ]$PROPDAMAGE = substormdata[substormdata$PROPDMGEXP == "H", ]$PROPDMG * 10^2
substormdata[substormdata$PROPDMGEXP == "K", ]$PROPDAMAGE = substormdata[substormdata$PROPDMGEXP == "K", ]$PROPDMG * 10^3
substormdata[substormdata$PROPDMGEXP == "k", ]$PROPDAMAGE = substormdata[substormdata$PROPDMGEXP == "k", ]$PROPDMG * 10^3
substormdata[substormdata$PROPDMGEXP == "m", ]$PROPDAMAGE = substormdata[substormdata$PROPDMGEXP == "m", ]$PROPDMG * 10^6
substormdata[substormdata$PROPDMGEXP == "M", ]$PROPDAMAGE = substormdata[substormdata$PROPDMGEXP == "M", ]$PROPDMG * 10^6
substormdata[substormdata$PROPDMGEXP == "B", ]$PROPDAMAGE = substormdata[substormdata$PROPDMGEXP == "B", ]$PROPDMG * 10^9
substormdata$CROPDAMAGE <- 0
substormdata[substormdata$CROPDMGEXP == "H", ]$CROPDAMAGE = substormdata[substormdata$CROPDMGEXP == "H", ]$CROPDMG * 10^2
substormdata[substormdata$CROPDMGEXP == "k", ]$CROPDAMAGE = substormdata[substormdata$CROPDMGEXP == "k", ]$CROPDMG * 10^3
substormdata[substormdata$CROPDMGEXP == "K", ]$CROPDAMAGE = substormdata[substormdata$CROPDMGEXP == "K", ]$CROPDMG * 10^3
substormdata[substormdata$CROPDMGEXP == "m", ]$CROPDAMAGE = substormdata[substormdata$CROPDMGEXP == "m", ]$CROPDMG * 10^6
substormdata[substormdata$CROPDMGEXP == "M", ]$CROPDAMAGE = substormdata[substormdata$CROPDMGEXP == "M", ]$CROPDMG * 10^6
substormdata[substormdata$CROPDMGEXP == "B", ]$CROPDAMAGE = substormdata[substormdata$CROPDMGEXP == "B", ]$CROPDMG * 10^9

Total damage to properties and crops

economic_damage <- aggregate(PROPDAMAGE + CROPDAMAGE ~ EVTYPE, substormdata, sum)
names(economic_damage) = c("EVENT_TYPE", "TOTAL_DAMAGE")
economic_damage <- arrange(economic_damage, desc(TOTAL_DAMAGE))
economic_damage <- economic_damage[1:20, ]
economic_damage$TOTAL_DAMAGE <- economic_damage$TOTAL_DAMAGE/10^9
economic_damage$EVENT_TYPE <- factor(economic_damage$EVENT_TYPE, levels = economic_damage$EVENT_TYPE)
head(economic_damage)
##          EVENT_TYPE TOTAL_DAMAGE
## 1             FLOOD    150.31968
## 2 HURRICANE/TYPHOON     71.91371
## 3           TORNADO     57.35211
## 4       STORM SURGE     43.32354
## 5              HAIL     18.75822
## 6       FLASH FLOOD     17.56213

RESULT

Barplot showing the top 20 most harmful events that have the greatest economic consequences across the United States

names_of_events <- economic_damage$EVENT_TYPE
barplot(t(economic_damage[,2]),names.arg = names_of_events, col = "green", beside= T, cex.names= 0.8, las=2, ylim = c(0,152), 
        main = "Harmful events that caused the greatest damage",ylab = "Damage in the USD(10^9)")

FLOODS are the most devasted weather event that have the greatest economic damages across the U.S.