library(ggplot2)
library(tidyverse)
library(lubridate)
library(knitr)
This report shows the principal climatic problems are affecting the population in EEUU, using the NOAA Storm Database, this database takes information from the National Climatic Data Center (NCDC) regularly receives Storm Data from the National Weather Service (NWS) and Storm Data is an official publication of the National Oceanic and Atmospheric Administration (NOAA) which documents the occurrence of storms and other significant weather phenomena having sufficient intensity to cause loss of life, injuries, significant property damage, and/or disruption to commerce.
storms <- read_csv("repdata_data_StormData.csv",
col_types = cols(BGN_DATE = col_datetime(format = "%m/%d/%Y %H:%M:%S"),
BGN_TIME = col_time(format = "%H%M")))
events <- storms %>% group_by(EVTYPE) %>% summarise(fatalities = sum(FATALITIES), injuries = sum(INJURIES)) %>% gather(key = "effect", value = value, injuries, -EVTYPE, fatalities) %>% filter(value > 1000)
head(events)
## # A tibble: 6 x 3
## EVTYPE effect value
## <chr> <chr> <dbl>
## 1 EXCESSIVE HEAT injuries 6525
## 2 FLASH FLOOD injuries 1777
## 3 FLOOD injuries 6789
## 4 HAIL injuries 1361
## 5 HEAT injuries 2100
## 6 HEAVY SNOW injuries 1021
economic <- storms %>% select(EVTYPE, PROPDMG, PROPDMGEXP) %>% group_by(EVTYPE, PROPDMG, PROPDMGEXP) %>% filter(!is.na(PROPDMGEXP) & PROPDMG >= 100 & PROPDMGEXP == "M")
head(economic)
## # A tibble: 6 x 3
## # Groups: EVTYPE, PROPDMG, PROPDMGEXP [1]
## EVTYPE PROPDMG PROPDMGEXP
## <chr> <dbl> <chr>
## 1 TORNADO 250 M
## 2 TORNADO 250 M
## 3 TORNADO 250 M
## 4 TORNADO 250 M
## 5 TORNADO 250 M
## 6 TORNADO 250 M
ggplot(events, aes(EVTYPE, value, fill = effect)) + geom_bar(stat = "identity", position = "dodge") + coord_flip() + xlab("Event type") + ylab("Affected people") + ggtitle("Events that affect more than a thousand people")
ggplot(economic, aes(EVTYPE, PROPDMG, fill = EVTYPE)) + geom_bar(stat = "identity") + coord_flip() + theme_bw() + xlab("Event type") + ylab("Millions") + ggtitle("Events with greatest economic consequences") + theme(legend.position = "none")