NOAA ANALYSIS

We want to address the question about what are the most dangerous events in the USA according to the NOAA database that record all these phenomena from 1950 to 2011

storm_df <- read.csv("repdata_data_StormData.csv")

let’s analyse the database to calculate which event caused more damage to people summing all the observations during all period, doing so I will group the type of event column and sum all the fatalities and injures, I will then plot the resulting dataframe to see the results.

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
dangerous_df <- group_by(storm_df, EVTYPE)
dangerous_df <- dangerous_df %>%  summarise(FATALITIES = sum(FATALITIES), INJURIES = sum(INJURIES))

Let’s make a summary to retrieve the mean of the sums

summary(dangerous_df)
##     EVTYPE            FATALITIES         INJURIES      
##  Length:985         Min.   :   0.00   Min.   :    0.0  
##  Class :character   1st Qu.:   0.00   1st Qu.:    0.0  
##  Mode  :character   Median :   0.00   Median :    0.0  
##                     Mean   :  15.38   Mean   :  142.7  
##                     3rd Qu.:   0.00   3rd Qu.:    0.0  
##                     Max.   :5633.00   Max.   :91346.0

And now let’s take only the values above the mean to clean up the observations and make the plot more readable

dangerous_df <- dangerous_df[dangerous_df$FATALITIES > 16 & dangerous_df$INJURIES > 143, ]

Let’s add the ggplot2 library and make 2 plots to check which event has the most high peak

library(ggplot2)
g <- ggplot(dangerous_df, aes(EVTYPE, FATALITIES))
g + geom_point(size = 0.5) +  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+ labs(x = "EVENTS")

P <- ggplot(dangerous_df, aes(EVTYPE, INJURIES))
P + geom_point(size = 0.5) +  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+ labs(x = "EVENTS") 

Let’ order the database one time for fatalities and another time for injuries and sort it in descending order to see which events were the most dangerous

dangerous_df<- dangerous_df[with(dangerous_df, order(desc(dangerous_df$FATALITIES))),]
head(dangerous_df)
## # A tibble: 6 × 3
##   EVTYPE         FATALITIES INJURIES
##   <chr>               <dbl>    <dbl>
## 1 TORNADO              5633    91346
## 2 EXCESSIVE HEAT       1903     6525
## 3 FLASH FLOOD           978     1777
## 4 HEAT                  937     2100
## 5 LIGHTNING             816     5230
## 6 TSTM WIND             504     6957
dangerous_df<- dangerous_df[with(dangerous_df, order(desc(dangerous_df$INJURIES))),]
head(dangerous_df)
## # A tibble: 6 × 3
##   EVTYPE         FATALITIES INJURIES
##   <chr>               <dbl>    <dbl>
## 1 TORNADO              5633    91346
## 2 TSTM WIND             504     6957
## 3 FLOOD                 470     6789
## 4 EXCESSIVE HEAT       1903     6525
## 5 LIGHTNING             816     5230
## 6 HEAT                  937     2100

As we can see Tornado is by way the most dangerous event causing more death and injuries, followed by Excessive Heat and Floods

Now we will analyse the property and agricultural loss due to meteorological events as we see in the databases there are 2 columns named “PROPDMGEXP” and “CROPDMGEXP” which multiply the adjacent columns with symbols as B for billions, M for millions and K for thousands, let’s first clean the database and get rid of the columns that are not useful to address the question

# use only useful variables
prop_loss_df <- storm_df[, c("BGN_DATE","COUNTY", "COUNTYNAME", "STATE", "EVTYPE", "PROPDMG", "PROPDMGEXP", "CROPDMG", "CROPDMGEXP")]

now I need to transform the character column “CROPDMGEXP” and “PROPDMGEXP” that have a character as multiplicator for the adjacent column as explained above to do this I have implemented a function that return an extra column “RESULT” with numeric values in relation with the letters B M or K

get_multiplier <- function(column){
  
  for(i in 1:length(column)){
    if(!is.na(column[i])){
        if(column[i] == "M" | column[i] == "m") column[i] = 1000000
        else if(column[i] == "B" | column[i] == "b") column[i] = 1000000000
        else if(column[i] == "K" | column[i] == "k") column[i] = 1000
        else column[i] = 0
      }
    }
  as.numeric(column)
}

And now let’s create an extra column with the numeric results

prop_loss_df$MULT_CROP <- get_multiplier(prop_loss_df$CROPDMGEXP)
prop_loss_df$MULT_PROP <- get_multiplier(prop_loss_df$PROPDMGEXP)

And now an extra column for the numeric value of the loss for each section or property or agriculture

prop_loss_df$CROP_LOSS <- prop_loss_df$CROPDMG * prop_loss_df$MULT_CROP
prop_loss_df$PROP_LOSS <- prop_loss_df$PROPDMG * prop_loss_df$MULT_PROP

and now let’s do a first check on the resulting data

summary(prop_loss_df$CROP_LOSS)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.000e+00 0.000e+00 0.000e+00 5.442e+04 0.000e+00 5.000e+09
summary(prop_loss_df$PROP_LOSS)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.000e+00 0.000e+00 0.000e+00 4.736e+05 5.000e+02 1.150e+11

I will take into consideration only those entry that are higher than the average, in order to consider the phenomena that caused bigger economic loss to property and reduce the entries of the plots to be more readable, in addition I will sum all the loss across all the years of observation to see which event had the most severe impact on the economy of the Country.

prop_loss_df <- subset(prop_loss_df, CROP_LOSS > 2.222e+06 & PROP_LOSS > 4.736e+05 )
economic_loss <- group_by(prop_loss_df, EVTYPE)
economic_loss <- economic_loss %>% summarise(PROP_LOSS = sum(PROP_LOSS), CROP_LOSS = sum(CROP_LOSS))

And now let’s plot the 2 economic losses analysed, the agricultural and the property loss, to have a first quick look of the most catastrophic events.

mylist <- unique(economic_loss$EVTYPE)
g <- ggplot(economic_loss, aes(EVTYPE, CROP_LOSS ))
g + geom_point(size = 0.5) +  theme( axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, size = 6)) +scale_x_discrete(limit = mylist)+ labs(x = "EVENTS", y = "CROP LOSS")

p <- ggplot(economic_loss, aes(EVTYPE, PROP_LOSS ))
p + geom_point(size = 0.5) +  theme( axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, size = 6)) +scale_x_discrete(limit = mylist)+ labs(x = "EVENTS", y = "PROPERTY LOSS")

And let’s make a summary of the events to have the numeric result of the study

economic_loss<- economic_loss[with(economic_loss, order(desc(economic_loss$CROP_LOSS))),]
head(economic_loss)
## # A tibble: 6 × 3
##   EVTYPE               PROP_LOSS  CROP_LOSS
##   <chr>                    <dbl>      <dbl>
## 1 RIVER FLOOD         5020500000 5022000000
## 2 ICE STORM             80350000 5019250000
## 3 HURRICANE           7582870000 2676310000
## 4 FLOOD             117335711000 2620760000
## 5 HURRICANE/TYPHOON  25067755000 2592750000
## 6 FLASH FLOOD         1226805600 1008890000
economic_loss<- economic_loss[with(economic_loss, order(desc(economic_loss$PROP_LOSS))),]
head(economic_loss)
## # A tibble: 6 × 3
##   EVTYPE                        PROP_LOSS  CROP_LOSS
##   <chr>                             <dbl>      <dbl>
## 1 FLOOD                      117335711000 2620760000
## 2 HURRICANE/TYPHOON           25067755000 2592750000
## 3 HURRICANE                    7582870000 2676310000
## 4 RIVER FLOOD                  5020500000 5022000000
## 5 HURRICANE OPAL               2168000000   19000000
## 6 TORNADOES, TSTM WIND, HAIL   1600000000    2500000

I suspect that there are few outliers in the dataset maybe an error in the entries, it seems that the highest loss in agriculture arise from river floods and Ice storms, while in the section property there is an outlier caused by floods, I need to extract those entries to check if the events really occurred at the place and date provided.

out_crop <- subset(prop_loss_df, CROP_LOSS==5.000e+09)
out_prop <- subset(prop_loss_df, PROP_LOSS == 1.150e+11)
out_crop
##                 BGN_DATE COUNTY                     COUNTYNAME STATE
## 198389 8/31/1993 0:00:00      1      ADAMS, CALHOUN AND JERSEY    IL
## 211900  2/9/1994 0:00:00      0 MSZ001 - 023 - 025 - 026 - 034    MS
##             EVTYPE PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP MULT_CROP MULT_PROP
## 198389 RIVER FLOOD       5          B       5          B     1e+09     1e+09
## 211900   ICE STORM     500          K       5          B     1e+09     1e+03
##        CROP_LOSS PROP_LOSS
## 198389     5e+09     5e+09
## 211900     5e+09     5e+05
out_prop
##                BGN_DATE COUNTY COUNTYNAME STATE EVTYPE PROPDMG PROPDMGEXP
## 605953 1/1/2006 0:00:00     55       NAPA    CA  FLOOD     115          B
##        CROPDMG CROPDMGEXP MULT_CROP MULT_PROP CROP_LOSS PROP_LOSS
## 605953    32.5          M     1e+06     1e+09  32500000  1.15e+11

Let’s investigate on the internet if on 31st of August 1993 there was a river flood in Illinois and if the damage was 5 Billion dollars. According to the website we can state that it was a quite big disaster and that is consistent with the observation.

Let’s also check on 9th of February 1994 there was an Ice storm in Missisipi that caused 5 Billion dollars loss in agriculture. and yes, it was really an exceptional phenomena and caused a great damage to agricultural industry.

And finally if on 1st of January 2006 there was a flood in California that caused a loss of 115 Bilion dollars. Also this was a really huge disaster and caused Billion of dollars damage and it’s consistent with the observations. It seems from the research that these exceptional phenomena really occurred at the date given

RESULTS

Regarding human lives “Tornado” is by way the most dangerous event causing more death and injuries, followed by “Excessive Heat” and “Floods” While the events that caused bigger damages to property were “Floods” and “Hurricane/Typhoons”, and regarding Agriculture were “River Floods” and “Ice Storms”.