Synopsis

Aim of this report is to present the most harmfull weather events regearding public health and economic damages using NOAA Storm Database.

Problem

The basic goal of this analysis is to explore the NOAA Storm Database and answer some basic questions about severe weather events. This short report tries to answer these questions:

Data Processing

Here i will describe the process of data processing.

At first we get data file and load it into R.

if(!file.exists("bzfile.csv.bz2")) {
  download.file("https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2", "bzfile.csv.bz2")
}
data <- read.csv("bzfile.csv.bz2")

Then we load neccessary libraries

Next we prepare data about health effects

# calculation
health<- summarise(group_by(data, EVTYPE), F = sum(FATALITIES) , I = sum(INJURIES))
names(health) <- c("EVTYPE","Fatalities", "Injuries")

# data preparation for charting
chart_health <- arrange(melt(health, id.vars = "EVTYPE"),desc(value))
chart_health <- rbind( chart_health[chart_health$variable =="Fatalities" , ][1:5,], chart_health[chart_health$variable =="Injuries" , ][1:5,])

Next we prepare data about economy effects. As a first thing we need to decipher metric abbreviations into multiples of 10.

# conversion of units from factor to character
data$PROPDMGEXP<- as.character(data$PROPDMGEXP)
data$CROPDMGEXP<- as.character(data$CROPDMGEXP)

# conversion of units to number of zeros for 10^x operation
PROPDMGEXP_numerator <- with(data, case_when (PROPDMGEXP == "H" ~ as.numeric(2),
                                              PROPDMGEXP == "K" ~ as.numeric(3),
                                              PROPDMGEXP == "M" ~ as.numeric(6),
                                              PROPDMGEXP == "B" ~ as.numeric(9),
                                              TRUE ~ as.numeric(0)))

# conversion of units to number of zeros for 10^x operation
CROPDMGEXP_numerator <- with(data, case_when (CROPDMGEXP == "H" ~ as.numeric(2),
                                              CROPDMGEXP == "K" ~ as.numeric(3),
                                              CROPDMGEXP == "M" ~ as.numeric(6),
                                              CROPDMGEXP == "B" ~ as.numeric(9),
                                              TRUE ~ as.numeric(0)))

# binding of derived fields to initial data 
data<- cbind(data,PROPDMGEXP_numerator, CROPDMGEXP_numerator)

Then we can calculate economy damages.

# calculation
economy <- summarise(
                  group_by(
                        filter(data, !is.null(PROPDMGEXP_numerator) & !is.null(CROPDMGEXP_numerator)), 
                        EVTYPE), 
                  P = sum(PROPDMG * 10^PROPDMGEXP_numerator),
                  C = sum(CROPDMG * 10^CROPDMGEXP_numerator)
                  )
                  
names(economy) <- c("EVTYPE","Property","Crops")

# data preparation for charting
chart_economy <- arrange(melt(economy, id.vars = "EVTYPE"),desc(value))
chart_economy <- rbind( chart_economy[chart_economy$variable =="Property" , ][1:5,], chart_economy[chart_economy$variable =="Crops" , ][1:5,])

Results

Now lets answer those questions.

Across the United States, these event types are most harmful with respect to population health:

ggplot(chart_health, aes(x=EVTYPE, y=value, fill = variable, label = value)) + geom_bar(stat="identity") + labs(x="Event type", y="Amount", title="Most harmfull events with respect to population health in United States") + theme(axis.text.x=element_text(angle=50,vjust=0.5)) + geom_text(size = 3) + facet_grid( variable ~ .)

As we can see the most harmfull events to population are Tornados (in both injuries and deaths).

Across the United States, these event types are most harmful with respect to economical damage:

ggplot(chart_economy, aes(x=EVTYPE, y=value, fill = variable, label = sprintf("%1.2f M", value/10^6))) +  geom_bar(stat="identity") + labs(x="Event type", y="Amount", title="Most harmfull events with respect to economucal damages") + theme(axis.text.x=element_text(angle=50,vjust=0.5)) + geom_text(size = 3) 

The greatest amount of damage done to crops is by drought, followed by flood.

Most damaging to property is a flood.