Synopsis

The basic goal of this document was to explore the NOAA Storm Database and answer some basic questions about severe weather events using analysis that can consist of tables, figures, or other summaries and show all the code in R to support the analysis.

Data Processing

for this analysis i decide to use the following packages for organize, analyse and visualize the results of my analysis.

library(rio)
library(dplyr)
library(tibble)
library(ggplot2)
library(gridExtra)

Load the information

In this part of my code i decide to use de library rio for load the dataset in R.

For this i used the function import() as we can see in the next code line.

data <- import("./data/repdata_data_StormData.csv")

Results

For respond the question of which events were most harmful with respect to population health, we try to analyse in two different ways.

    - Looking for the total of Injuries in United States.
    - Looking for the total of Fatalities in United States

and compare how was the behavior foe each of them.

harmful <- data %>% 
        select(EVTYPE,INJURIES, FATALITIES) %>% 
        group_by(EVTYPE) %>% 
        summarise(INJURIES=sum(INJURIES), FATALITIES= sum(FATALITIES))

harmful <- arrange(harmful, desc(FATALITIES), desc(INJURIES))

harmful_top <- head(harmful,10)

as_tibble(harmful_top)
## # A tibble: 10 × 3
##    EVTYPE         INJURIES FATALITIES
##    <chr>             <dbl>      <dbl>
##  1 TORNADO           91346       5633
##  2 EXCESSIVE HEAT     6525       1903
##  3 FLASH FLOOD        1777        978
##  4 HEAT               2100        937
##  5 LIGHTNING          5230        816
##  6 TSTM WIND          6957        504
##  7 FLOOD              6789        470
##  8 RIP CURRENT         232        368
##  9 HIGH WIND          1137        248
## 10 AVALANCHE           170        224

showing that Tornado is the most harmful event for injuries and fatalities in United States in that period or time

p1 <- harmful %>%
 filter(INJURIES >= 1100L & INJURIES <= 91346L) %>%
 ggplot() +
  aes(x = reorder(EVTYPE, INJURIES) , y = INJURIES) +
  geom_col(fill = "#112446") +
  theme_minimal()+
        coord_flip()

p2 <- harmful %>%
 filter(FATALITIES >= 224L & FATALITIES <= 5633L) %>%
 ggplot() +
  aes(x = reorder(EVTYPE, FATALITIES), y = FATALITIES) +
  geom_col(fill = "orange") +
  theme_minimal()+
        coord_flip()

grid.arrange(p1, p2, ncol = 1)

Finally for see which of the events was the one that generate the biggest economic consequence, we replicate the last process but using the variables EVTYPE, PROPDMG, PROPDMGEXP, CROPDMG, CROPDMGEXP.

For this first i decide to multiply the variables PROPDMG and CROPDMG for their respective exponential for see the complete number group by each event and them add the grouped values to find the total cost for each event and create a new column for tehe total of the cost of the cost calculated and see wich is the total cost for each event.

cost <- data %>% 
        select(EVTYPE, PROPDMG, PROPDMGEXP, CROPDMG, CROPDMGEXP) %>% 
        mutate(PROPDMG_final = case_when(PROPDMGEXP == "K" ~ PROPDMG * 1000,
                                         PROPDMGEXP == "M" ~ PROPDMG * 1000000,
                                         PROPDMGEXP == "B" ~ PROPDMG * 1000000000,
                                         TRUE~0)) %>% 
        mutate(CROPDMG_final = case_when(CROPDMGEXP == "K" ~ CROPDMG * 1000,
                                         CROPDMGEXP == "M" ~ CROPDMG * 1000000,
                                         CROPDMGEXP == "B" ~ CROPDMG * 1000000000,
                                         TRUE~0)) 

cost_final <- cost %>% 
        select(EVTYPE, PROPDMG_final, CROPDMG_final) %>% 
        group_by(EVTYPE) %>% 
        summarise(PROPDMG_final = sum(PROPDMG_final), PROPDMG_final = sum(CROPDMG_final))

cost_final$final_cost <- cost_final$PROPDMG_final + cost_final$PROPDMG_final

cost_final %>%
 filter(final_cost >= 967610099 & final_cost <= 289315419600) %>%
 ggplot() +
  aes(x = reorder(EVTYPE, final_cost), y = final_cost) +
  geom_col(fill = "#112446") +
  coord_flip() +
  theme_minimal()

This analysis found that the event that generate more economic damages in unite states was drought following by flood